Module: ROM::Processor::Transproc::Functions

Extended by:
Transproc::Registry
Defined in:
lib/rom/processor/transproc.rb

Constant Summary collapse

INVALID_INJECT_UNION_VALUE =
"%s attribute: block is required for :from with union value.".freeze

Class Method Summary collapse

Class Method Details

.filter_empty(arr) ⇒ Object



35
36
37
# File 'lib/rom/processor/transproc.rb', line 35

def self.filter_empty(arr)
  arr.reject { |row| row.values.all?(&:nil?) }
end

.get(arr, idx) ⇒ Object



31
32
33
# File 'lib/rom/processor/transproc.rb', line 31

def self.get(arr, idx)
  arr[idx]
end

.identity(tuple) ⇒ Object



27
28
29
# File 'lib/rom/processor/transproc.rb', line 27

def self.identity(tuple)
  tuple
end

.inject_union_value(tuple, name, keys, coercer) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/rom/processor/transproc.rb', line 39

def self.inject_union_value(tuple, name, keys, coercer)
  raise ROM::MapperMisconfiguredError, INVALID_INJECT_UNION_VALUE % [name] if !coercer

  values = tuple.values_at(*keys)
  result = coercer.call(*values)

  tuple.merge(name => result)
end