Class: Morfo::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/morfo.rb

Class Method Summary collapse

Class Method Details

.field(*field_path) ⇒ Object



6
7
8
9
10
# File 'lib/morfo.rb', line 6

def self.field *field_path
  act = Morfo::Actions::Field.new(field_path, mapping_actions)
  mapping_actions[field_path] = act
  act
end

.morf(input) ⇒ Object



12
13
14
# File 'lib/morfo.rb', line 12

def self.morf input
  input.map { |row| morf_single(row) }
end

.morf_single(input) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/morfo.rb', line 16

def self.morf_single input
  output = {}
  mapping_actions.each do |field_path, action|
    deep_merge!(output, store_value(action.execute(input), field_path))
  end
  output
end