Module: ROM::Processor::Transformer::Functions
- Extended by:
- Dry::Transformer::Registry
- Defined in:
- lib/rom/processor/transformer.rb
Constant Summary collapse
- INVALID_INJECT_UNION_VALUE =
"%s attribute: block is required for :from with union value."
Class Method Summary collapse
- .filter_empty(arr) ⇒ Object
- .get(arr, idx) ⇒ Object
- .inject_union_value(tuple, name, keys, coercer) ⇒ Object
Class Method Details
.filter_empty(arr) ⇒ Object
33 34 35 |
# File 'lib/rom/processor/transformer.rb', line 33 def self.filter_empty(arr) arr.reject { |row| row.values.all?(&:nil?) } end |
.get(arr, idx) ⇒ Object
29 30 31 |
# File 'lib/rom/processor/transformer.rb', line 29 def self.get(arr, idx) arr[idx] end |
.inject_union_value(tuple, name, keys, coercer) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/rom/processor/transformer.rb', line 37 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 |