mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
5438f6866e
ActionDispatch::Request#deep_munge was introduced as a private method, but was turned into a public one for the use of ActionDispatch::ParamsParser. I have extracted it into ActionDispatch::Request::Utils, so it does not get mixed up with the Request public methods.
24 lines
495 B
Ruby
24 lines
495 B
Ruby
module ActionDispatch
|
|
class Request < Rack::Request
|
|
class Utils # :nodoc:
|
|
class << self
|
|
# Remove nils from the params hash
|
|
def deep_munge(hash)
|
|
hash.each do |k, v|
|
|
case v
|
|
when Array
|
|
v.grep(Hash) { |x| deep_munge(x) }
|
|
v.compact!
|
|
hash[k] = nil if v.empty?
|
|
when Hash
|
|
deep_munge(v)
|
|
end
|
|
end
|
|
|
|
hash
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|