Last active
September 24, 2015 17:53
-
-
Save kirillzh/763e30a55016f7978bba 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
require 'active_support/core_ext/object/deep_dup.rb' | |
class Object | |
def deep_reject!(*keys) | |
if is_a?(Hash) | |
keys.each { |k| delete(k) } | |
values.each { |v| v.deep_reject!(*keys) } | |
elsif is_a?(Array) | |
each { |x| x.deep_reject!(*keys) } | |
end | |
self | |
end | |
def deep_reject(*keys) | |
if [Hash, Array].include? self.class | |
deep_dup.deep_reject!(*keys) | |
else | |
self | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment