Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/vapir-common/external/core_extensions.rb
Instance Method Summary collapse
-
#select_keys(*keys) ⇒ Object
returns a hash whose keys are the intersection of the keys of this hash and the keys given as arguments to this function.
Instance Method Details
#select_keys(*keys) ⇒ Object
returns a hash whose keys are the intersection of the keys of this hash and the keys given as arguments to this function. values are the same as in this hash.
40 41 42 43 44 |
# File 'lib/vapir-common/external/core_extensions.rb', line 40 def select_keys(*keys) keys.inject(self.class.new) do |hash,key| self.key?(key) ? hash.merge(key => self[key]) : hash end end |