Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/with_validations/core_ext/hash.rb
Instance Method Summary collapse
-
#delete_keys!(*keys) ⇒ Hash
Removes ‘*keys` from self.
-
#slice(*keys) ⇒ Hash
Creates a sub-hash from ‘self` with the keys from `*keys`.
Instance Method Details
#delete_keys!(*keys) ⇒ Hash
Note:
keys in ‘*keys` not present in `self` are silently ignored.
Removes ‘*keys` from self.
8 9 10 11 12 |
# File 'lib/with_validations/core_ext/hash.rb', line 8 def delete_keys!(*keys) keys.each do |key| self.delete(key) end end |
#slice(*keys) ⇒ Hash
Note:
keys in ‘*keys` not present in `self` are silently ignored.
Creates a sub-hash from ‘self` with the keys from `*keys`.
18 19 20 |
# File 'lib/with_validations/core_ext/hash.rb', line 18 def slice(*keys) self.select { |k,v| keys.include?(k) } end |