Class: Cascade::RowProcessor
- Inherits:
-
Object
- Object
- Cascade::RowProcessor
- Extended by:
- Configuration
- Defined in:
- lib/cascade/row_processor.rb
Constant Summary collapse
- DEFAULT_PROCESSOR =
->(value) { value }
Instance Method Summary collapse
-
#call(row) ⇒ Hash
Iterates through object using columns values supported keys as keys for iterating, then parse it by curresponding parser.
-
#initialize(options = {}) ⇒ RowProcessor
constructor
A new instance of RowProcessor.
Methods included from Configuration
Constructor Details
#initialize(options = {}) ⇒ RowProcessor
Returns a new instance of RowProcessor.
16 17 18 19 |
# File 'lib/cascade/row_processor.rb', line 16 def initialize( = {}) @options = @columns_matching = [:columns_matching] || ColumnsMatching.new end |
Instance Method Details
#call(row) ⇒ Hash
Iterates through object using columns values supported keys as keys for iterating, then parse it by curresponding parser.
26 27 28 29 30 31 32 |
# File 'lib/cascade/row_processor.rb', line 26 def call(row) @columns_matching.supported_keys.inject({}) do |result, key| raw_value = row.fetch(@columns_matching.index(key)) value = receive_presenter(key).call(raw_value) result.merge(key => value) end end |