class Trailblazer::Activity::TaskWrap::Pipeline

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.

Attributes

sequence[R]

Public Class Methods

append(pipe, _, insertion) click to toggle source
# File lib/trailblazer/activity/task_wrap/pipeline.rb, line 35
def self.append(pipe, _, insertion) # TODO: test me.
  Pipeline.new(pipe.sequence + [insertion])
end
insert_after(pipe, after_id, insertion) click to toggle source
# File lib/trailblazer/activity/task_wrap/pipeline.rb, line 27
def self.insert_after(pipe, after_id, insertion)
  index = pipe.sequence.find_index { |(id, _)| id == after_id }

  seq = pipe.sequence.dup

  Pipeline.new(seq.insert(index+1, insertion))
end
insert_before(pipe, before_id, insertion) click to toggle source
# File lib/trailblazer/activity/task_wrap/pipeline.rb, line 19
def self.insert_before(pipe, before_id, insertion)
  index = pipe.sequence.find_index { |(id, _)| id == before_id }

  seq = pipe.sequence.dup

  Pipeline.new(seq.insert(index, insertion))
end
new(sequence) click to toggle source
# File lib/trailblazer/activity/task_wrap/pipeline.rb, line 7
def initialize(sequence)
  @sequence = sequence # [[id, task], ..]
end

Public Instance Methods

call(wrap_ctx, original_args) click to toggle source
# File lib/trailblazer/activity/task_wrap/pipeline.rb, line 11
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