Method: Hash#only

Defined in:
lib/lab419/core/hash.rb

#only(*keys) ⇒ Object



7
8
9
10
11
# File 'lib/lab419/core/hash.rb', line 7

def only *keys
  keys.inject Hash.new do | h, k |
    has_key?( k ) ? h.merge( k => self[k] ) : h
  end
end