mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Fix Long Method rubocop issue
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user