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