class Burner::Library::Collection::Unshift
Adds the values of the from_registers
to the to_register array. All existing elements in the register array will be shifted upwards.
Expected Payload input: Array containing names of registers whose values to prepend. Payload output: An array with the from_registers
' payload added to the beginning.
Attributes
from_registers[R]
Public Class Methods
new(from_registers: [], name: '', register: DEFAULT_REGISTER)
click to toggle source
Calls superclass method
Burner::JobWithRegister::new
# File lib/burner/library/collection/unshift.rb, line 23 def initialize(from_registers: [], name: '', register: DEFAULT_REGISTER) super(name: name, register: register) @from_registers = Array(from_registers) freeze end
Public Instance Methods
perform(output, payload)
click to toggle source
# File lib/burner/library/collection/unshift.rb, line 31 def perform(output, payload) output.detail("Prepending registers: '#{from_registers}' to: '#{register}'") payload_register = array(payload[register]) from_registers.each do |from_register| from_register_value = payload[from_register] payload_register.unshift(from_register_value) end end