Created
May 2, 2009 01:22
-
-
Save jaredatron/105352 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Hash | |
| # Like has_key? but accepts an list of keys and returns true of self has every | |
| # key in the array | |
| def has_keys?(key, *other_keys) | |
| other_keys.unshift key | |
| other_keys.flatten.all?{ |k| self.has_key? k } | |
| end | |
| # Like has_key? but accepts a list of keys and returns true of self has any | |
| # key in the array | |
| def has_any_key?(key, *other_keys) | |
| other_keys.unshift key | |
| other_keys.flatten.any?{ |k| self.has_key? k } | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment