Permalink
Browse files

Merge pull request #2 from elorenzo1138/multiplicity_fixes

Array-vs-single fixes
  • Loading branch information...
2 parents e67c622 + fd24118 commit cfd8b91f4267e843d545741251262a3443b564ec Eric Lorenzo committed Jun 1, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/happymapper.rb
View
@@ -211,7 +211,7 @@ def parse(xml, options = {})
namespace = @namespace
# If the XML specified is an Node then we have what we need.
- if xml.is_a?(Nokogiri::XML::Node)
+ if xml.is_a?(Nokogiri::XML::Node) && !xml.is_a?(Nokogiri::XML::Document)
node = xml
else
@@ -289,6 +289,9 @@ def parse(xml, options = {})
nodes
end
+ # Nothing matching found, we can go ahead and return
+ return ( ( options[:single] || root ) ? nil : [] ) if nodes.size == 0
+
# If the :limit option has been specified then we are going to slice
# our node results by that amount to allow us the ability to deal with
# a large result set of data.

0 comments on commit cfd8b91

Please sign in to comment.