Module: Trailblazer::Activity::Railway::DSL::Fail

Defined in:
lib/trailblazer/activity/railway.rb

Constant Summary collapse

SUCCESS_TO_FAILURE_CONNECTOR =
{Linear::Normalizer::OutputTuples.Output(:success) => Linear::Strategy.Track(:failure)}

Class Method Summary collapse

Class Method Details

.connect_success_to_failure(ctx, non_symbol_options:) ⇒ Object



56
57
58
# File 'lib/trailblazer/activity/railway.rb', line 56

def connect_success_to_failure(ctx, non_symbol_options:, **)
  ctx[:non_symbol_options] = SUCCESS_TO_FAILURE_CONNECTOR.merge(non_symbol_options)
end

.merge_magnetic_to(ctx) ⇒ Object



50
51
52
# File 'lib/trailblazer/activity/railway.rb', line 50

def merge_magnetic_to(ctx, **)
  ctx[:magnetic_to] = :failure
end

.Normalizer(**options) ⇒ Object

Change some parts of the step-Normalizer pipeline. We’re bound to using a very primitive Pipeline API, remember, we don’t have a DSL at this point!



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/trailblazer/activity/railway.rb', line 34

def Normalizer(**options)
  pipeline = Linear::Normalizer.prepend_to( # TODO: replace path.magnetic_to???
    DSL.Normalizer(**options), # grab Railway::DSL::Normalizer.
    Path::DSL::PREPEND_TO,
    {
      "railway.magnetic_to.fail" => Linear::Normalizer.Task(Fail.method(:merge_magnetic_to)),
    }
  )

  pipeline = Linear::Normalizer.replace(
    pipeline,
    "path.step.add_success_connector",
    ["railway.fail.success_to_failure", Linear::Normalizer.Task(Fail.method(:connect_success_to_failure))],
  )
end