diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-06-21 15:07:15 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-06-21 15:07:15 +0000 |
commit | 9e4461438f8ce584b635aca35579c36537a340ca (patch) | |
tree | 8c1b83901b2d7ee52d32eec792e6af1ca807e65f /activeresource/lib | |
parent | eb2e30ef249051713d8122a784d8fbfa378e7ae1 (diff) | |
download | rails-9e4461438f8ce584b635aca35579c36537a340ca.tar.gz rails-9e4461438f8ce584b635aca35579c36537a340ca.tar.bz2 rails-9e4461438f8ce584b635aca35579c36537a340ca.zip |
Added proper handling of arrays. Closes #8537 [hasmanyjosh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7074 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activeresource/lib')
-rw-r--r-- | activeresource/lib/active_resource/connection.rb | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/activeresource/lib/active_resource/connection.rb b/activeresource/lib/active_resource/connection.rb index d41171270c..8245c797b3 100644 --- a/activeresource/lib/active_resource/connection.rb +++ b/activeresource/lib/active_resource/connection.rb @@ -81,11 +81,7 @@ module ActiveResource end def xml_from_response(response) - if response = from_xml_data(Hash.from_xml(response.body)) - response.first - else - nil - end + from_xml_data(Hash.from_xml(response.body)) end @@ -150,21 +146,12 @@ module ActiveResource # Manipulate from_xml Hash, because xml_simple is not exactly what we # want for ActiveResource. def from_xml_data(data) - case data - when Hash - if data.keys.size == 1 - case data.values.first - when Hash then [ from_xml_data(data.values.first) ] - when Array then from_xml_data(data.values.first) - else data.values.first - end - else - data.each_key { |key| data[key] = from_xml_data(data[key]) } - data - end - when Array then data.collect { |val| from_xml_data(val) } - else data + if data.is_a?(Hash) && data.keys.size == 1 + data.values.first + else + data end end + end end |