class Burner::Library::Collection::Zip
This job can take two arrays and coalesces them by index. For example:
input:
base_register: [ 'hello', 'bugs' ] with_register: [ 'world', 'bunny' ]
output:
register: [ ['hello', 'world'], ['bugs', 'bunny'] ]
Expected Payload input: array of objects. Expected Payload input: array of objects. Payload output: An array of two-dimensional arrays.
Attributes
base_register[R]
with_register[R]
Public Class Methods
new( with_register:, base_register: DEFAULT_REGISTER, name: '', register: DEFAULT_REGISTER )
click to toggle source
Calls superclass method
Burner::JobWithRegister::new
# File lib/burner/library/collection/zip.rb, line 27 def initialize( with_register:, base_register: DEFAULT_REGISTER, name: '', register: DEFAULT_REGISTER ) super(name: name, register: register) @base_register = base_register.to_s @with_register = with_register.to_s freeze end
Public Instance Methods
perform(output, payload)
click to toggle source
# File lib/burner/library/collection/zip.rb, line 41 def perform(output, payload) base_data = array(payload[base_register]) with_data = array(payload[with_register]) output.detail("Combining register: #{base_register} (#{base_data.length} record(s))") output.detail("With register: #{with_register} (#{with_data.length} record(s))") payload[register] = base_data.zip(with_data) end