Class: Trailblazer::Activity::TaskWrap::Input

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

Overview

Note:

Assumption: we always have :input and :output, where :input produces a Context and :output decomposes it.

TaskWrap step to compute the incoming Context for the wrapped task. This allows renaming, filtering, hiding, of the options passed into the wrapped task.

Both Input and Output are typically to be added before and after task_wrap.call_task.

Defined Under Namespace

Classes: Scoped

Instance Method Summary collapse

Constructor Details

#initialize(filter) ⇒ Input

Returns a new instance of Input.



62
63
64
# File 'lib/trailblazer/activity/task_wrap/variable_mapping.rb', line 62

def initialize(filter)
  @filter = filter
end

Instance Method Details

#call(wrap_ctx, original_args, circuit_options) ⇒ Object

‘original_args` are the actual args passed to the wrapped task: [ [options, ..], circuit_options ]



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/trailblazer/activity/task_wrap/variable_mapping.rb', line 68

def call( (wrap_ctx, original_args), circuit_options )
  # let user compute new ctx for the wrapped task.
  input_ctx = apply_filter(*original_args) # FIXME: THIS SHOULD ALWAYS BE A _NEW_ Context.

  wrap_ctx = wrap_ctx.merge( vm_original_ctx: original_args[0][0] ) # remember the original ctx

  # decompose the original_args since we want to modify them.
  (original_ctx, original_flow_options), original_circuit_options = original_args

  # instead of the original Context, pass on the filtered `input_ctx` in the wrap.
  return Trailblazer::Activity::Right, [ wrap_ctx, [[input_ctx, original_flow_options], original_circuit_options] ]
end