Class: Trailblazer::Activity::TaskWrap::Output
- Inherits:
-
Object
- Object
- Trailblazer::Activity::TaskWrap::Output
- Defined in:
- lib/trailblazer/activity/task_wrap/variable_mapping.rb
Overview
TaskWrap step to compute the outgoing Context from the wrapped task. This allows renaming, filtering, hiding, of the options returned from the wrapped task.
Defined Under Namespace
Classes: Unscoped
Instance Method Summary collapse
-
#call(wrap_ctx, original_args, **circuit_options) ⇒ Object
Runs the user filter and replaces the ctx in ‘wrap_ctx` with the filtered one.
-
#initialize(filter) ⇒ Output
constructor
A new instance of Output.
Constructor Details
#initialize(filter) ⇒ Output
Returns a new instance of Output.
118 119 120 |
# File 'lib/trailblazer/activity/task_wrap/variable_mapping.rb', line 118 def initialize(filter) @filter = filter end |
Instance Method Details
#call(wrap_ctx, original_args, **circuit_options) ⇒ Object
Runs the user filter and replaces the ctx in ‘wrap_ctx` with the filtered one.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/trailblazer/activity/task_wrap/variable_mapping.rb', line 123 def call( (wrap_ctx, original_args), ** ) (original_ctx, ), = original_args returned_ctx, _ = wrap_ctx[:return_args] # this is the Context returned from `call`ing the task. original_ctx = wrap_ctx[:vm_original_ctx] # let user compute the output. output_ctx = @filter.(original_ctx, returned_ctx, **) wrap_ctx = wrap_ctx.merge( return_args: [output_ctx, ] ) # and then pass on the "new" context. return Trailblazer::Activity::Right, [ wrap_ctx, original_args ] end |