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



35
36
37
# File 'core/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 'core/lib/rom/processor/transproc.rb', line 31

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

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



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

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