Class: DataMaps::Converter::Map
- Inherits:
-
Base
- Object
- Executable
- Base
- DataMaps::Converter::Map
- Defined in:
- lib/data_maps/converter/map.rb
Overview
Map values
Instance Attribute Summary
Attributes inherited from Executable
Instance Method Summary collapse
-
#after_initialize ⇒ Object
The after initialize callback.
-
#execute(data) ⇒ Object
The execute method to convert the given data.
Methods inherited from Executable
#initialize, valid_collection?
Constructor Details
This class inherits a constructor from DataMaps::Executable
Instance Method Details
#after_initialize ⇒ Object
The after initialize callback
8 9 10 |
# File 'lib/data_maps/converter/map.rb', line 8 def after_initialize @option = option.with_indifferent_access end |
#execute(data) ⇒ Object
The execute method to convert the given data
15 16 17 18 19 20 21 |
# File 'lib/data_maps/converter/map.rb', line 15 def execute(data) case data when Array then data.map{ |d| option[d] } when Hash then Hash[data.map{ |k,v| [k, option[v]] }] else option[data] || data end end |