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: Merge, 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

.method(name) ⇒ Object

TODO: remove me when old tW extension API is deprecated.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/trailblazer/activity/task_wrap/pipeline.rb', line 27

def self.method(name)
  new_name = {
    insert_before: :Prepend,
    insert_after: :Append,
    append: :Append,
    prepend: :Prepend
  }.fetch(name)

  warn "[Trailblazer] Using `Trailblazer::Activity::TaskWrap::Pipeline.method(:#{name})` is deprecated.
Please use the new API: #FIXME!!!"

  Trailblazer::Activity::Adds::Insert.method(new_name)
end

.Row(id, task) ⇒ Object



41
42
43
# File 'lib/trailblazer/activity/task_wrap/pipeline.rb', line 41

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