From 55360ddf7fd5f3fedc327476bf07aac3ba698e0d Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Mon, 19 Aug 2013 15:23:03 -0300 Subject: Use each_with_object --- actionpack/lib/action_dispatch/http/parameters.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_dispatch/http/parameters.rb b/actionpack/lib/action_dispatch/http/parameters.rb index ca10da702c..dcb299ed03 100644 --- a/actionpack/lib/action_dispatch/http/parameters.rb +++ b/actionpack/lib/action_dispatch/http/parameters.rb @@ -64,16 +64,14 @@ module ActionDispatch 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 -- cgit v1.2.3