ActiveResource and handling of arrays

ActiveResource uses xml_simple from activesupport to turn XML to essentially a big Hash or Array, after which point ActiveResource::Base's load() (actually find_or_create_resource_for, called from load) takes care of the remaining magic of building ActiveResource::Base instances to encapsulate the parsed XML data.

Currently, if you have some XML that looks roughly like this:

<my-model>   <id type="integer">1</id>   <some_attrib>blah blah</some_attrib>   ...   <related-entities>      <related-entity>          ...      </related-entity>       ...   </related-entities> </my-model>

What happens is that you get an AR instance for my_model, in which you have an attribute called "related_entities" which is a Hash, and which contains a single attribute called "related_entity" which is an Array. This makes sense given xml_simple's parse/collapse/merge trickery, but seems counter-intuitive for ActiveResource. I'd rather expect to have an AR instance for my_model, with a "related_entities" attribute which is itself immediately an Array of related_entity AR children.

Make sense?

I see Jeremy Kemper commited a fix for this not too long after the post:

r5167 | bitsweat | 2006-09-22 17:29:54 -0400 (Fri, 22 Sep 2006) | 1 line workaround collections loaded as :people => { :person => [{..attrs..}, {..attrs..}] }

Thank you!

-B