Skip to content

Instantly share code, notes, and snippets.

@dinks
Created November 2, 2013 22:27
Show Gist options
  • Select an option

  • Save dinks/7284178 to your computer and use it in GitHub Desktop.

Select an option

Save dinks/7284178 to your computer and use it in GitHub Desktop.
Hash Blacklist and Whitelist
class Hash
def except(*blacklist)
reject {|key, value| blacklist.include?(key) }
end
def only(*whitelist)
reject {|key, value| !whitelist.include?(key) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment