module Buff::Extensions::Hash::Except
Borrowd and modified from {github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/except.rb}
Public Instance Methods
except(*keys)
click to toggle source
Return a hash that includes everything but the given keys. This is useful for limiting a set of parameters to everything but a few known toggles:
@person.update(params[:person].except(:admin))
# File lib/buff/extensions/hash/except.rb, line 10 def except(*keys) dup.except!(*keys) end
except!(*keys)
click to toggle source
Replaces the hash without the given keys.
# File lib/buff/extensions/hash/except.rb, line 15 def except!(*keys) keys.each { |key| delete(key) } self end