1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactor ActionDispatch::Http::Parameters#normalize_encode_params

This commit is contained in:
Genadi Samokovarov 2013-06-04 13:34:43 +03:00
parent c2f3efffd9
commit 998d03fddb

View file

@ -64,17 +64,13 @@ module ActionDispatch
end
new_hash = {}
params.each do |k, v|
new_key = k.is_a?(String) ? k.dup.force_encoding(Encoding::UTF_8).encode! : k
new_hash[new_key] =
case v
when Hash
normalize_encode_params(v)
when Array
v.map! {|el| normalize_encode_params(el) }
else
normalize_encode_params(v)
end
params.each do |key, val|
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