public Method

Hash.only(*allowed)

Returns a new Hash with only the selected keys:

{ :one => 1, :two => 2, :three => 3 }.only(:one)
#=> { :one => 1 }

Source Code

# File merb/core_ext/hash.rb, line 117
def only(*allowed) 
  reject { |k,v| !allowed.include?(k) }
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.