lib/xmlhasher/node.rb in xmlhasher-0.0.1 vs lib/xmlhasher/node.rb in xmlhasher-0.0.2
- old
+ new
@@ -16,10 +16,10 @@
if children.size == 1
child = children.first
h[name] = child.to_hash
else
if children.map(&:name).uniq.size == 1
- h[name] = children.map { |child| child.to_hash }
+ h[name] = children.inject({}) { |r, child| (r[child.name] ||= []) << child.to_hash[child.name]; r }
else
h[name] = children.inject({}) { |r, child| r.merge!(child.to_hash); r }
end
end
end