Class: Morfo::Base
- Inherits:
-
Object
- Object
- Morfo::Base
- Defined in:
- lib/morfo.rb
Class Method Summary collapse
- .field(*field_path) ⇒ Object
- .morf(input, options = {}) ⇒ Object
- .morf_single(input, options = {}) ⇒ Object
Class Method Details
.field(*field_path) ⇒ Object
10 11 12 13 14 |
# File 'lib/morfo.rb', line 10 def self.field *field_path act = Morfo::Actions::Field.new(field_path, mapping_actions) mapping_actions[field_path] = act act end |
.morf(input, options = {}) ⇒ Object
16 17 18 |
# File 'lib/morfo.rb', line 16 def self.morf input, = {} input.map { |row| morf_single(row, ) } end |
.morf_single(input, options = {}) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/morfo.rb', line 20 def self.morf_single input, = {} output = {} mapping_actions.each do |field_path, action| output.deeper_merge!(store_value(action.execute(input), field_path, )) end output end |