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 /activesupport/lib/active_support/core_ext/hash/conversions.rb | |
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 'activesupport/lib/active_support/core_ext/hash/conversions.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/conversions.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index 2334bb671b..2cccd9c30e 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -163,6 +163,20 @@ module ActiveSupport #:nodoc: else content end + elsif value['type'] == 'array' + child_key, entries = value.detect { |k,v| k != 'type' } # child_key is throwaway + if entries.nil? + [] + else + case entries.class.to_s # something weird with classes not matching here. maybe singleton methods breaking is_a? + when "Array" + entries.collect { |v| typecast_xml_value(v) } + when "Hash" + [typecast_xml_value(entries)] + else + raise "can't typecast #{entries.inspect}" + end + end elsif value['type'] == 'string' && value['nil'] != 'true' "" else |