Method: DataMapper::Ext::Hash.except

Defined in:
lib/dm-core/support/ext/hash.rb

.except(hash, *keys) ⇒ Hash

Returns a hash that includes everything but the given keys.

Examples:

hash = { :one => 1, :two => 2, :three => 3 }
Ext::Hash.except(hash, :one, :two) # => { :three => 3 }

Parameters:

  • hash (Hash)

    The hash from which to pick the key/value pairs.

  • *keys (Array)

    The hash keys to exclude.

Returns:

  • (Hash)

    A new hash without the specified keys.



33
34
35
# File 'lib/dm-core/support/ext/hash.rb', line 33

def self.except(hash, *keys)
  self.except!(hash.dup, *keys)
end