Created
August 7, 2015 16:22
-
-
Save kirillzh/71129ebb7f678f9ab58a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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