Class: Trailblazer::Activity::TaskWrap::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/activity/task_wrap/pipeline.rb

Overview

This “circuit” is optimized for

a) merging speed at run-time, since features like tracing will be applied here.
b) execution speed. Every task in the real circuit is wrapped with one of us.

It doesn’t come with built-in insertion mechanics (except for Pipeline.prepend). Please add/remove steps using the Adds methods.

Defined Under Namespace

Classes: Row, TaskAdapter

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sequence) ⇒ Pipeline

Returns a new instance of Pipeline.



10
11
12
# File 'lib/trailblazer/activity/task_wrap/pipeline.rb', line 10

def initialize(sequence)
  @sequence = sequence # [[id, task], ..]
end

Class Method Details

.Row(id, task) ⇒ Object



26
27
28
# File 'lib/trailblazer/activity/task_wrap/pipeline.rb', line 26

def self.Row(id, task)
  Row[id, task]
end

Instance Method Details

#call(wrap_ctx, original_args) ⇒ Object

Execute the pipeline and call all its steps, passing around the wrap_ctx.



15
16
17
18
19
# File 'lib/trailblazer/activity/task_wrap/pipeline.rb', line 15

def call(wrap_ctx, original_args)
  @sequence.each { |(_id, task)| wrap_ctx, original_args = task.(wrap_ctx, original_args) }

  return wrap_ctx, original_args
end

#to_aObject

Comply with the Adds interface.



22
23
24
# File 'lib/trailblazer/activity/task_wrap/pipeline.rb', line 22

def to_a
  @sequence
end