2 # http://www.bigbold.com/snippets/posts/show/2178
3 # http://blog.caboo.se/articles/2006/06/11/stupid-hash-tricks
5 # An example utilisation of these methods in a controller is:
7 # # some script kiddie also passed in :bee, which we don't want tampered with _here_.
8 # @model = Model.create(params.pass(:foo, :bar))
12 # lets through the keys in the argument
13 # >> {:one => 1, :two => 2, :three => 3}.pass(:one)
16 keys = keys.first if keys.first.is_a?(Array)
18 tmp.delete_if {|k,v| ! keys.include?(k.to_sym) }
19 tmp.delete_if {|k,v| ! keys.include?(k.to_s) }
23 # blocks the keys in the arguments
24 # >> {:one => 1, :two => 2, :three => 3}.block(:one)
25 # => {:two=>2, :three=>3}
27 keys = keys.first if keys.first.is_a?(Array)
29 tmp.delete_if {|k,v| keys.include?(k.to_sym) }
30 tmp.delete_if {|k,v| keys.include?(k.to_s) }