Permalink
Browse files

Use each_with_object

  • Loading branch information...
1 parent e5945e4 commit 55360ddf7fd5f3fedc327476bf07aac3ba698e0d @spastorino spastorino committed Aug 19, 2013
Showing with 2 additions and 4 deletions.
  1. +2 −4 actionpack/lib/action_dispatch/http/parameters.rb
View
6 actionpack/lib/action_dispatch/http/parameters.rb
@@ -64,16 +64,14 @@ def normalize_encode_params(params)
if params.has_key?(:tempfile)
UploadedFile.new(params)
else
- new_hash = {}
- params.each do |key, val|
+ params.each_with_object({}) do |(key, val), new_hash|
new_key = key.is_a?(String) ? key.dup.force_encoding(Encoding::UTF_8).encode! : key
new_hash[new_key] = if val.is_a?(Array)
val.map! { |el| normalize_encode_params(el) }
else
normalize_encode_params(val)
end
- end
- new_hash.with_indifferent_access
+ end.with_indifferent_access
end
else
params

0 comments on commit 55360dd

Please sign in to comment.