Created
May 7, 2015 12:00
-
-
Save polamjag/2678086ee0c026f0c3fb to your computer and use it in GitHub Desktop.
super dirty deep_except in Ruby
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
# deep_except | |
class Hash | |
def deep_except!(*keys) | |
keys.each { |key| delete(key) } | |
self.each { |k, v| | |
v.except!(*keys) if v.is_a? Hash | |
} | |
self | |
end | |
def deep_except(*keys) | |
dup.deep_except!(*keys) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment