class OpenNebula::DocumentPoolJSON
Constants
- TEMPLATE_TAG
Public Instance Methods
factory(element_xml)
click to toggle source
# File lib/opennebula/document_pool_json.rb, line 22 def factory(element_xml) doc = OpenNebula::DocumentJSON.new(element_xml, @client) doc.load_body doc end
to_json(pretty_generate=true)
click to toggle source
Generates a json representing the object
@param [true, false] pretty_generate @return [String] json representing the object
# File lib/opennebula/document_pool_json.rb, line 33 def to_json(pretty_generate=true) hash = self.to_hash if hash['DOCUMENT_POOL'] && hash['DOCUMENT_POOL']['DOCUMENT'] if !hash['DOCUMENT_POOL']['DOCUMENT'].instance_of?(Array) array = [hash['DOCUMENT_POOL']['DOCUMENT']] hash['DOCUMENT_POOL']['DOCUMENT'] = array.compact end hash['DOCUMENT_POOL']['DOCUMENT'].each { |doc| body = doc['TEMPLATE']["#{TEMPLATE_TAG}"] if body b_hash = JSON.parse(body) doc['TEMPLATE']["#{TEMPLATE_TAG}"] = b_hash end } end if pretty_generate JSON.pretty_generate hash else hash.to_json end end