dam5s/happymapper — pull request #40 by geoffwa (2013-07-26 05:14:48+00:00)
Title: 'Embedded' attributes break parsing when parent element is not present

```ruby
#!/usr/bin/env ruby

require 'rubygems'
require 'happymapper' # assuming you only have nokogiri-happymapper installed

xml = <

EOXML

class Foo
include HappyMapper

tag 'foo'
element :moo, String, :attributes => { :guh => String }, :single => true
end

parsed = Foo.parse(xml, :single => true)
```

results in the following (shortened paths for easier reading):
```
/home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper/element.rb:38:in `handle_attributes_option': undefined method `attribute_nodes' for nil:NilClass (NoMethodError)
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper/element.rb:21:in `find'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper/item.rb:36:in `from_xml_node'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper.rb:390:in `block (3 levels) in parse'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper.rb:389:in `each'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper.rb:389:in `block (2 levels) in parse'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper.rb:376:in `map'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper.rb:376:in `block in parse'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:237:in `block in each'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:236:in `upto'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-1.6.0/lib/nokogiri/xml/node_set.rb:236:in `each'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper.rb:374:in `each_slice'
from /home/ggiesemann/2.0.0-p247/gems/nokogiri-happymapper-0.5.7/lib/happymapper.rb:374:in `parse'
```

We parse XML with a lot of optional elements, and I was looking at switching over from happymapper which is how I discovered this bug.