aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/request
diff options
context:
space:
mode:
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