Method: AbstractMapper::Functions.restrict

Defined in:
lib/abstract_mapper/functions.rb

.restrict(hash, default_hash) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Restricts the hash by keys and values of the default one

Parameters:

  • hash (Hash)
  • default_hash (Hash)

Returns:

  • (Hash)

    <description>



95
96
97
98
99
# File 'lib/abstract_mapper/functions.rb', line 95

def self.restrict(hash, default_hash)
  keys = default_hash.keys
  values = default_hash.merge(hash).values
  Hash[keys.zip(values)]
end