Module: HashExtension::ClassMethods

Defined in:
lib/oha_extensions/hash_extension.rb

Instance Method Summary collapse

Instance Method Details

#from_xml_string(s, options = {}) ⇒ Object

Generates a hash from XML. This is specifically being used generate JSON for the API. It makes the assumption that elements contain arrays

must be explicitly specified.  Assuming otherwise generates larger JSON.
This also utilizes XML attributes which Hash.from_xml ignores.


105
106
107
108
# File 'lib/oha_extensions/hash_extension.rb', line 105

def from_xml_string(s, options = {})
  options = {:array_nodes => [], :parent_array_nodes => []}.merge(options)
  return node_to_hash(Nokogiri.parse(s).children.first, options)
end