Module: Marconi::SmartXML

Defined in:
lib/marconi/smart_xml.rb

Class Method Summary collapse

Class Method Details

.parse(xml) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/marconi/smart_xml.rb', line 8

def parse(xml)
  return nil unless xml
  hash = Hash.from_xml(xml)
  return nil unless hash

  # If the top-level object is a hash, rails's deserializer puts it 
  # under the key "hash".  If it's an array, it uses "object".  Simple
  # values like numbers and strings can't be XML docs all by themselves
  # so we don't need to consider any other cases.

  indifferentize(hash['hash'] || hash['objects'])
end