Class: Burner::Library::Value::Transform

Inherits:
JobWithRegister show all
Defined in:
lib/burner/library/value/transform.rb

Overview

Transform the current value of the register through a Realize::Pipeline. This will transform the entire value, as opposed to the b/collection/transform job, which will iterate over each row/record in a dataset and transform each row/record.

Expected Payload input: anything. Payload output: anything.

Constant Summary

Constants inherited from JobWithRegister

JobWithRegister::BLANK

Instance Attribute Summary collapse

Attributes inherited from JobWithRegister

#register

Attributes inherited from Job

#name

Instance Method Summary collapse

Methods included from Util::Arrayable

#array

Constructor Details

#initialize(name: '', register: DEFAULT_REGISTER, separator: '', transformers: []) ⇒ Transform

Returns a new instance of Transform.



22
23
24
25
26
27
28
29
30
# File 'lib/burner/library/value/transform.rb', line 22

def initialize(name: '', register: DEFAULT_REGISTER, separator: '', transformers: [])
  super(name: name, register: register)

  resolver = Objectable.resolver(separator: separator)

  @pipeline = Realize::Pipeline.new(transformers, resolver: resolver)

  freeze
end

Instance Attribute Details

#pipelineObject (readonly)

Returns the value of attribute pipeline.



20
21
22
# File 'lib/burner/library/value/transform.rb', line 20

def pipeline
  @pipeline
end

Instance Method Details

#perform(_output, payload) ⇒ Object



32
33
34
# File 'lib/burner/library/value/transform.rb', line 32

def perform(_output, payload)
  payload[register] = pipeline.transform(payload[register], payload.time)
end