Class: Darthjee::CoreExt::Hash::ToHashMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/darthjee/core_ext/hash/to_hash_mapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ ToHashMapper

Returns a new instance of ToHashMapper.



7
8
9
# File 'lib/darthjee/core_ext/hash/to_hash_mapper.rb', line 7

def initialize(hash)
  @hash = hash
end

Instance Method Details

#mapObject



11
12
13
14
15
16
17
# File 'lib/darthjee/core_ext/hash/to_hash_mapper.rb', line 11

def map
  {}.tap do |new_hash|
    hash.each do |k, v|
      new_hash[k] = yield(k, v)
    end
  end
end