aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-09-22 12:18:22 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2010-09-22 18:08:03 -0300
commit418190d55c19b19bd2f1153a4367f04263557aee (patch)
tree9781a6ba498c3bbb77161e47ff8fe1ec332b6e5f /activesupport/lib
parent8cfc6012f443f17fa51fe22aefa25323e87338b5 (diff)
downloadrails-418190d55c19b19bd2f1153a4367f04263557aee.tar.gz
rails-418190d55c19b19bd2f1153a4367f04263557aee.tar.bz2
rails-418190d55c19b19bd2f1153a4367f04263557aee.zip
Refactor inject use in hash conversions.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/conversions.rb10
1 files changed, 2 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb
index 7e929848a9..4e8ec5a3a8 100644
--- a/activesupport/lib/active_support/core_ext/hash/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -114,10 +114,7 @@ class Hash
elsif value['type'] && value.size == 1 && !value['type'].is_a?(::Hash)
nil
else
- xml_value = value.inject({}) do |h,(k,v)|
- h[k] = typecast_xml_value(v)
- h
- end
+ xml_value = Hash[value.map { |k,v| [k, typecast_xml_value(v)] }]
# Turn { :files => { :file => #<StringIO> } into { :files => #<StringIO> } so it is compatible with
# how multipart uploaded files from HTML appear
@@ -136,10 +133,7 @@ class Hash
def unrename_keys(params)
case params.class.to_s
when "Hash"
- params.inject({}) do |h,(k,v)|
- h[k.to_s.tr("-", "_")] = unrename_keys(v)
- h
- end
+ Hash[params.map { |k,v| [k.to_s.tr("-", "_"), unrename_keys(v)] } ]
when "Array"
params.map { |v| unrename_keys(v) }
else