1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-25 02:50:08 +03:00

bug #1397: Define DOCUMENT_TYPE in the child class

This commit is contained in:
Daniel Molina 2012-07-30 12:47:42 +02:00
parent 9f1e6e5822
commit ec5e4649b0
2 changed files with 20 additions and 12 deletions

View File

@ -18,15 +18,15 @@ require 'OpenNebula/Pool'
module OpenNebula
# All subclasses must define the Document::TYPE constant.
# All subclasses must define the DOCUMENT_TYPE constant.
#
# @example
# require 'OpenNebula/Document'
#
# module OpenNebula
# class CustomObject < Document
#
# Document::TYPE = 400
#
# DOCUMENT_TYPE = 400
#
# end
# end
@ -65,7 +65,7 @@ module OpenNebula
#
# @param [Nokogiri::XML::Node, REXML::Element] xml string
# created by the build_xml() method
# @param [OpenNebula::Client] client the xml-rpc client
# @param [OpenNebula::Client] client the xml-rpc client
#
# @return [Document] the new object
#
@ -94,7 +94,7 @@ module OpenNebula
# @return [nil, OpenNebula::Error] nil in case of success, Error
# otherwise
def allocate(description)
super(DOCUMENT_METHODS[:allocate], description, TYPE)
super(DOCUMENT_METHODS[:allocate], description, document_type)
end
# Deletes the Document
@ -187,6 +187,10 @@ module OpenNebula
end
end
def document_type
self.class::DOCUMENT_TYPE
end
private
def set_publish(published)

View File

@ -18,7 +18,7 @@ require 'OpenNebula/Pool'
module OpenNebula
# All subclasses must define the DocumentPool::TYPE constant
# All subclasses must define the DOCUMENT_TYPE constant
# and the factory method.
#
# @example
@ -27,7 +27,7 @@ module OpenNebula
# module OpenNebula
# class CustomObjectPool < DocumentPool
#
# DocumentPool::TYPE = 400
# DOCUMENT_TYPE = 400
#
# def factory(element_xml)
# OpenNebula::CustomObject.new(element_xml, @client)
@ -72,22 +72,26 @@ module OpenNebula
def info(*args)
case args.size
when 0
info_filter(DOCUMENT_POOL_METHODS[:info],@user_id,-1,-1, TYPE)
info_filter(DOCUMENT_POOL_METHODS[:info],@user_id,-1,-1, document_type)
when 3
info_filter(DOCUMENT_POOL_METHODS[:info],args[0],args[1],args[2], TYPE)
info_filter(DOCUMENT_POOL_METHODS[:info],args[0],args[1],args[2], document_type)
end
end
def info_all()
return super(DOCUMENT_POOL_METHODS[:info], TYPE)
return super(DOCUMENT_POOL_METHODS[:info], document_type)
end
def info_mine()
return super(DOCUMENT_POOL_METHODS[:info], TYPE)
return super(DOCUMENT_POOL_METHODS[:info], document_type)
end
def info_group()
return super(DOCUMENT_POOL_METHODS[:info], TYPE)
return super(DOCUMENT_POOL_METHODS[:info], document_type)
end
def document_type
self.class::DOCUMENT_TYPE
end
end
end