Trouble consuming REST from OpenStreetMap - self-closing elements, perhaps?

I'm consuming's REST api:

and I get an error when I try to run the following code in my
ActiveResource model:

  # GET /api/0.5/map?bbox=left,bottom,right,top
  def self.features(left,bottom,right,top)
    find(:first, :from=>"/api/0.5/map?bbox=#{left},#{bottom},#{right},#


undefined method `collect!' for #<Hash:0x22f2798>
RAILS_ROOT: /Users/jeff/Desktop/whooz-osm/whooz-osm

Application Trace | Framework Trace | Full Trace
lib/active_resource/base.rb:595:in `instantiate_collection'
lib/active_resource/base.rb:559:in `find_every'
lib/active_resource/base.rb:508:in `find'
app/models/openstreetmap.rb:9:in `features'

I thought it was this patch, and perhaps it is, in a sense: (that's why i'm using my own
copy of base.rb; i used their patch)

But in fact, I think it may be because if you actually go to OSM's

you see that they're using self-closing elements, which aren't ever
used in REST examples, as far as I can tell. That is, they use:

<node foo="bar" />

instead of always:


Odd, since OSM is run on Rails anyways... so that gives me a Hash:

{"node"=>[{"lon"=>"11.5411444", "user"=>"lesi", (...) which "node" is the only node element. Looks like it's not
recognizing it as self-closing, and treating the rest of the xml as
part of that element.

In any case, it's the following part of /active_resource/base.rb which
is causing the problem:

        def instantiate_collection(collection, prefix_options = {})
          # collection.collect! { |record| instantiate_record(record,
prefix_options) }
          puts collection.inspect
          if collection.is_a?(Hash) && collection.size == 1
            value = collection.values.first
            if value.is_a?(Array)
              value.collect! { |record| instantiate_record(record,
prefix_options) }
              [ instantiate_record(value, prefix_options) ]
            collection.collect! { |record| instantiate_record(record,
prefix_options) }

And I'm not sure how to patch AR to be able to read self-closing
elements... i think it's in /active_resource/formats/xml_format.rb,
but it's kind of opaque to me. Wonder if you have any thoughts on
this? Are self-closing elements a valid expression of REST xml? Can I
filter/reformat in my AR model, or should I extend whatever XML parser
AR is using... rexml, i'd guess... to appropriately read this?


My good friend Robert ( responded with
this excellent overview with which I got things running in about 20
lines of code: