mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
31 lines
650 B
Ruby
31 lines
650 B
Ruby
module ActionDispatch
|
|
class Request < Rack::Request
|
|
class Utils # :nodoc:
|
|
|
|
mattr_accessor :perform_deep_munge
|
|
self.perform_deep_munge = true
|
|
|
|
class << self
|
|
# Remove nils from the params hash
|
|
def deep_munge(hash, keys = [])
|
|
return hash unless perform_deep_munge
|
|
|
|
hash.each do |k, v|
|
|
keys << k
|
|
case v
|
|
when Array
|
|
v.grep(Hash) { |x| deep_munge(x, keys) }
|
|
v.compact!
|
|
when Hash
|
|
deep_munge(v, keys)
|
|
end
|
|
keys.pop
|
|
end
|
|
|
|
hash
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|