Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/extensions/core/hash.rb

Instance Method Summary collapse

Instance Method Details

#except(*rejected) ⇒ Object

Returns a Hash containing only input keys. Method from merb-core.



4
5
6
# File 'lib/extensions/core/hash.rb', line 4

def except(*rejected)
  reject { |k,v| rejected.include?(k) }
end

#only(*allowed) ⇒ Object

Returns a new hash containing only the input keys. Method from merb-core.



14
15
16
# File 'lib/extensions/core/hash.rb', line 14

def only(*allowed)
  reject { |k,v| !allowed.include?(k) }
end

#reverse_merge(other_hash) ⇒ Object



8
9
10
# File 'lib/extensions/core/hash.rb', line 8

def reverse_merge(other_hash)
  other_hash.merge(self)
end