Class: Morfo::Base

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

Class Method Summary collapse

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, options = {}
  input.map { |row| morf_single(row, options) }
end

.morf_single(input, options = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/morfo.rb', line 20

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