Class: Trailblazer::Activity::DSL::Linear::VariableMapping::Pipe::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb

Direct Known Subclasses

Output

Instance Method Summary collapse

Constructor Details

#initialize(pipe, id: :vm_original_ctx) ⇒ Input

Returns a new instance of Input.



13
14
15
16
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb', line 13

def initialize(pipe, id: :vm_original_ctx)
  @pipe = pipe
  @id   = id
end

Instance Method Details

#call(wrap_ctx, original_args) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/trailblazer/activity/dsl/linear/feature/variable_mapping/runtime.rb', line 18

def call(wrap_ctx, original_args)
  (original_ctx, original_flow_options), original_circuit_options = original_args

  # let user compute new ctx for the wrapped task.
  pipe_ctx, _       = @pipe.({original_ctx: original_ctx, aggregate: {}}, original_args)
  ctx_from_input    = pipe_ctx[:input_ctx]

  wrap_ctx = wrap_ctx.merge(@id => original_ctx) # remember the original ctx under the key {@id}.

  # instead of the original Context, pass on the filtered `ctx_from_input` in the wrap.
  return wrap_ctx, [[ctx_from_input, original_flow_options], original_circuit_options]
end