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

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

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.filter_empty(arr) ⇒ Object



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

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

.get(arr, idx) ⇒ Object



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

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

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



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

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

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

  tuple.merge(name => result)
end