Method: Dry::Transformer::HashTransformations.map_values

Defined in:
lib/dry/transformer/hash_transformations.rb

.map_values(source_hash, fn) ⇒ Hash

Map all values in a hash using transformation function

Examples:

Dry::Transformer(:map_values, -> v { v.upcase })[:name => 'Jane']
# => {"name" => "JANE"}

Parameters:

  • (Hash)

Returns:

  • (Hash)


143
144
145
# File 'lib/dry/transformer/hash_transformations.rb', line 143

def self.map_values(source_hash, fn)
  Hash[source_hash].transform_values!(&fn)
end