Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use each_with_object

  • Loading branch information...
commit 55360ddf7fd5f3fedc327476bf07aac3ba698e0d 1 parent e5945e4
Santiago Pastorino spastorino authored
Showing with 2 additions and 4 deletions.
  1. +2 −4 actionpack/lib/action_dispatch/http/parameters.rb
6 actionpack/lib/action_dispatch/http/parameters.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.