class Burner::Library::Collection::Concatenate

Take the list of from_registers and concatenate each of their values together. Each from_value will be coerced into an array if it not an array.

Expected Payload input: array of objects. Payload output: An array of objects.

Attributes

from_registers[R]
to_register[R]

Public Class Methods

new(from_registers: [], name: '', to_register: DEFAULT_REGISTER) click to toggle source
Calls superclass method Burner::Job::new
# File lib/burner/library/collection/concatenate.rb, line 21
def initialize(from_registers: [], name: '', to_register: DEFAULT_REGISTER)
  super(name: name)

  @from_registers = Array(from_registers)
  @to_register    = to_register.to_s

  freeze
end

Public Instance Methods

perform(output, payload) click to toggle source
# File lib/burner/library/collection/concatenate.rb, line 30
def perform(output, payload)
  output.detail("Concatenating registers: '#{from_registers}' to: '#{to_register}'")

  payload[to_register] = from_registers.each_with_object([]) do |from_register, memo|
    from_register_value = array(payload[from_register])

    memo.concat(from_register_value)
  end
end