aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/request
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-07-21 18:14:18 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-07-21 18:14:18 -0700
commit52cf1a71b393486435fab4386a8663b146608996 (patch)
treec5ad81f223c32e0272eae653219cc4c66d672586 /actionpack/lib/action_dispatch/request
parent3f299296d15bff5735a430b9d2e33476e8f24f69 (diff)
downloadrails-52cf1a71b393486435fab4386a8663b146608996.tar.gz
rails-52cf1a71b393486435fab4386a8663b146608996.tar.bz2
rails-52cf1a71b393486435fab4386a8663b146608996.zip
rm `deep_munge`. You will live on in our hearts (and git history)
Now that we have encoding strategies, we can just walk the params hash once to encode as HWIA, and remove nils.
Diffstat (limited to 'actionpack/lib/action_dispatch/request')
-rw-r--r--actionpack/lib/action_dispatch/request/utils.rb30
1 files changed, 12 insertions, 18 deletions
diff --git a/actionpack/lib/action_dispatch/request/utils.rb b/actionpack/lib/action_dispatch/request/utils.rb
index 01fd5efd5e..3973ea6346 100644
--- a/actionpack/lib/action_dispatch/request/utils.rb
+++ b/actionpack/lib/action_dispatch/request/utils.rb
@@ -6,10 +6,14 @@ module ActionDispatch
self.perform_deep_munge = true
def self.normalize_encode_params(params)
- ParamEncoder.normalize_encode_params params
+ if perform_deep_munge
+ NoNilParamEncoder.normalize_encode_params params
+ else
+ ParamEncoder.normalize_encode_params params
+ end
end
- class ParamEncoder
+ class ParamEncoder # :nodoc:
# Convert nested Hash to HashWithIndifferentAccess.
#
def self.normalize_encode_params(params)
@@ -34,22 +38,12 @@ module ActionDispatch
end
end
- class << self
- # Remove nils from the params hash
- def deep_munge(hash)
- return hash unless perform_deep_munge
-
- hash.each do |k, v|
- case v
- when Array
- v.grep(Hash) { |x| deep_munge(x) }
- v.compact!
- when Hash
- deep_munge(v)
- end
- end
-
- hash
+ # Remove nils from the params hash
+ class NoNilParamEncoder < ParamEncoder # :nodoc:
+ def self.handle_array(params)
+ list = super
+ list.compact!
+ list
end
end
end