Class: Hashformer::Generate::Map
- Inherits:
-
Object
- Object
- Hashformer::Generate::Map
- Defined in:
- lib/hashformer/generate.rb
Overview
Internal representation of a mapping transformation. Do not instantiate directly; call Hashformer::Generate.map (or HF::G.map) instead.
Instance Method Summary collapse
-
#call(input_hash) ⇒ Object
Called to process the map on the given
input_hash
. -
#initialize(*keys_or_callables, &block) ⇒ Map
constructor
A new instance of Map.
Constructor Details
#initialize(*keys_or_callables, &block) ⇒ Map
Returns a new instance of Map.
15 16 17 18 |
# File 'lib/hashformer/generate.rb', line 15 def initialize(*keys_or_callables, &block) @keys = keys_or_callables @block = block end |
Instance Method Details
#call(input_hash) ⇒ Object
Called to process the map on the given input_hash
21 22 23 24 25 |
# File 'lib/hashformer/generate.rb', line 21 def call(input_hash) values = @keys.map{|k| Hashformer.get_value(input_hash, k)} values = @block.call(*values) if @block values end |