Class: Trailblazer::Macro::Nested::Decider

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/macro/nested.rb

Overview

TaskWrap step to run the decider. It’s part of the API that the decider sees the original ctx. So this has to be placed in tW because we this step needs to be run before In() filters to resemble the behavior from pre 2.1.12.

Instance Method Summary collapse

Constructor Details

#initialize(nested_activity_decider) ⇒ Decider

Returns a new instance of Decider.



55
56
57
# File 'lib/trailblazer/macro/nested.rb', line 55

def initialize(nested_activity_decider)
  @nested_activity_decider = Activity::Circuit.Step(nested_activity_decider, option: true)
end

Instance Method Details

#call(wrap_ctx, original_args) ⇒ Object

TaskWrap API.



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/trailblazer/macro/nested.rb', line 60

def call(wrap_ctx, original_args)
  (ctx, flow_options), original_circuit_options = original_args

  # FIXME: allow calling a Step task without the Binary decision (in Activity::TaskAdapter).
  nested_activity, _ = @nested_activity_decider.([ctx, flow_options], **original_circuit_options) # no TaskWrap::Runner because we shall not trace!

  new_flow_options = flow_options.merge(
    decision: nested_activity
  )

  return wrap_ctx, [[ctx, new_flow_options], original_circuit_options]
end