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.
Instance Method Summary collapse
-
#call(wrap_ctx, original_args) ⇒ Object
Runs your filter and replaces the ctx in ‘wrap_ctx` with the filtered one.
-
#initialize(filter, id:) ⇒ Output
constructor
A new instance of Output.
Constructor Details
#initialize(filter, id:) ⇒ Output
Returns a new instance of Output.
62 63 64 65 |
# File 'lib/trailblazer/activity/task_wrap/variable_mapping.rb', line 62 def initialize(filter, id:) @filter = filter @id = id end |
Instance Method Details
#call(wrap_ctx, original_args) ⇒ Object
Runs your filter and replaces the ctx in ‘wrap_ctx` with the filtered one.
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/trailblazer/activity/task_wrap/variable_mapping.rb', line 68 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 wrapped user task. original_ctx = wrap_ctx[@id] # grab the original ctx from before which was set in the {:input} filter. # let user compute the output. output_ctx = @filter.(returned_ctx, [original_ctx, ], **) wrap_ctx = wrap_ctx.merge( return_args: [output_ctx, ] ) # and then pass on the "new" context. return wrap_ctx, original_args end |