Skip to content

Commit

Permalink
Fixed bug that multiple xml_accessors with the same nested :in clause…
Browse files Browse the repository at this point in the history
… create a new element for every accessor.
  • Loading branch information
megle committed Jan 27, 2012
1 parent b4ed31d commit 842b822
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/roxml/xml/references.rb
Expand Up @@ -90,17 +90,20 @@ def several?

def wrap(xml, opts = {:always_create => false})
wrap_with = @auto_vals ? auto_wrapper : wrapper

return xml if !wrap_with || xml.name == wrap_with
if !opts[:always_create] && (child = xml.children.find {|c| c.name == wrap_with })
return child
end

wraps = wrap_with.to_s.split('/')
wraps.inject(xml){|node,wrap| XML.add_node(node, wrap)}
wraps.inject(xml) do |node,wrap|
if !opts[:always_create] && (child = node.children.find {|c| c.name == wrap })
child
else
XML.add_node(node, wrap)
end
end

end


def nodes_in(xml)
@default_namespace = xml.default_namespace
vals = xml.roxml_search(xpath, @instance.class.roxml_namespaces)
Expand Down

0 comments on commit 842b822

Please sign in to comment.