Class: Burner::Job

Inherits:
Object
  • Object
show all
Includes:
Util::Arrayable
Defined in:
lib/burner/job.rb

Overview

Abstract base class for all job subclasses. The only public method a subclass needs to implement #perform(output, payload) and then you can register it for use using the Burner::Jobs factory class method #register. An example of a registration:

Burner::Jobs.register('your_class', YourClass)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util::Arrayable

#array

Constructor Details

#initialize(name: '') ⇒ Job

Returns a new instance of Job.



21
22
23
# File 'lib/burner/job.rb', line 21

def initialize(name: '')
  @name = name.to_s
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/burner/job.rb', line 19

def name
  @name
end

Instance Method Details

#perform(output, _payload) ⇒ Object

There are only a few requirements to be considered a valid Burner Job:

1. The class responds to #name
2. The class responds to #perform(output, payload)

The #perform method takes in two arguments: output (an instance of Burner::Output) and payload (an instance of Burner::Payload). Jobs can leverage output to emit information to the pipeline’s log(s). The payload is utilized to pass data from job to job, with its most important attribute being #registers. The registers attribute is a mutable and accessible hash per the individual job’s context (meaning of it is unknown without understanding a job’s input and output value of #registers.). Therefore #register key values can mean anything and it is up to consumers to clearly document the assumptions of its use.

Returning false will short-circuit the pipeline right after the job method exits. Returning anything else besides false just means “continue”.



40
41
42
43
44
# File 'lib/burner/job.rb', line 40

def perform(output, _payload)
  output.detail("#perform not implemented for: #{self.class.name}")

  nil
end