Fix Long Method rubocop issue

This commit is contained in:
Luis Ramos
2020-11-06 11:34:16 +00:00
committed by Matt-Yorkley
parent 0152b4da55
commit 7e39d78733

View File

@@ -38,27 +38,31 @@ module ActionDispatch
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!
# This patch removes the following lines
# if v.empty?
# hash[k] = nil
# ActiveSupport::Notifications.instrument("deep_munge.action_controller",
# keys: keys)
# end
when Hash
deep_munge(v, keys)
end
keys.pop
hash.each do |key, value|
deep_munge_value(key, value, keys)
end
hash
end
def deep_munge_value(key, value, keys)
keys << key
case value
when Array
value.grep(Hash) { |x| deep_munge(x, keys) }
value.compact!
# This patch removes the following lines
# if v.empty?
# hash[k] = nil
# ActiveSupport::Notifications.instrument("deep_munge.action_controller",
# keys: keys)
# end
when Hash
deep_munge(value, keys)
end
keys.pop
end
end
end
end