Skip to content

Instantly share code, notes, and snippets.

@kirillzh
Created August 7, 2015 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirillzh/71129ebb7f678f9ab58a to your computer and use it in GitHub Desktop.
Save kirillzh/71129ebb7f678f9ab58a to your computer and use it in GitHub Desktop.
def deep_reject!(hash, keys)
if hash.is_a?(Hash)
Array(keys).each { |k| hash.delete(k) }
hash.values.each { |v| deep_reject!(v, keys) }
elsif hash.is_a?(Array)
hash.each { |x| deep_reject!(x, keys) }
end
hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment