Class: Kiba::Extend::Transforms::Merge::ConstantValues
- Inherits:
-
Object
- Object
- Kiba::Extend::Transforms::Merge::ConstantValues
- Defined in:
- lib/kiba/extend/transforms/merge/constant_values.rb
Overview
Note:
Uses ConstantValue to handle each pair in the constantmap
, so
check its behavior as well.
Merges the given constant values into the given target fields.
Example
Source data:
{name: 'Weddy'},
{name: 'Kernel', species: 'Numida meleagris'}
Used in pipeline as:
transform Merge::ConstantValues,
constantmap: {
species_common: 'guinea fowl',
species_binomial: 'Numida meleagris'
}
Results in:
{name: 'Weddy', species_common: 'guinea fowl', species_binomial: 'Numida meleagris' },
{name: 'Kernel', species: 'Numida meleagris', species_common: 'guinea fowl', species_binomial: 'Numida meleagris' }
Instance Method Summary collapse
-
#initialize(constantmap:) ⇒ ConstantValues
constructor
A new instance of ConstantValues.
-
#process(row) ⇒ Object
Constructor Details
#initialize(constantmap:) ⇒ ConstantValues
Returns a new instance of ConstantValues.
42 43 44 45 46 |
# File 'lib/kiba/extend/transforms/merge/constant_values.rb', line 42 def initialize(constantmap:) @mergers = constantmap.map do |target, value| Merge::ConstantValue.new(target: target, value: value) end end |
Instance Method Details
#process(row) ⇒ Object
49 50 51 52 |
# File 'lib/kiba/extend/transforms/merge/constant_values.rb', line 49 def process(row) mergers.each { |merger| merger.process(row) } row end |