module VantivLite::XML::Parser
Public Instance Methods
call(xml)
click to toggle source
# File lib/vantiv_lite/xml/parser.rb, line 6 def call(xml) hash_with(root(xml)) end
Private Instance Methods
hash_with(*nodes)
click to toggle source
# File lib/vantiv_lite/xml/parser.rb, line 12 def hash_with(*nodes) nodes.each_with_object({}) do |n, h| inject_or_merge!(h, n.name, value_with!(n)) end end
inject_or_merge!(hash, key, value)
click to toggle source
# File lib/vantiv_lite/xml/parser.rb, line 18 def inject_or_merge!(hash, key, value) if hash.key?(key) cv = hash[key] value = cv.is_a?(Array) ? cv.push(value) : [cv, value] end hash[key] = value end