dam5s/happymapper — pull request #8 by elorenzo1138 (2012-06-01 18:46:50+00:00)
Title: More consistent behavior WRT single objects vs arrays

There are two changes here:

- Passing a preparsed Nokogiri::XML::Document object into HappyMapper's parse now causes it to treat this as a root call to parse, same as if a raw string was passed in. Reading through the existing code it seems like this was always the intent, but that because a Document is a subclass of Node, it wouldn't ever reach the code to handle Document as root.

- When parse finds no matches and :single => true is set, return nil rather than an empty array. I believe that this is clearer. Also, without this change, the current behavior is inconsistent: Right now if you pass :single => true, you'll get either a nil or an empty array depending on whether or not you also pass a value for :in_groups_of.

I've added specs to exercise the new behavior, as well.