Module: Trailblazer::Activity::DSL::Linear::Helper::Path::Normalizer

Defined in:
lib/trailblazer/activity/dsl/linear/helper/path.rb

Overview

Normalizer steps to handle Path() macro.

Class Method Summary collapse

Class Method Details

.convert_paths_to_tracks(ctx, non_symbol_options:, block: false) ⇒ Object

Convert all occurrences of Path() to a corresponding Track. The Track instance contains all additional adds steps and is picked up in Normalizer.normalize_connections_from_dsl.



38
39
40
41
42
43
44
45
# File 'lib/trailblazer/activity/dsl/linear/helper/path.rb', line 38

def convert_paths_to_tracks(ctx, non_symbol_options:, block: false, **)
  new_tracks = non_symbol_options
    .find_all { |output, cfg| cfg.is_a?(Linear::PathBranch) }
    .collect {  |output, cfg| [output, Path.convert_path_to_track(block: block, **cfg.options)]  }
    .to_h

  ctx[:non_symbol_options] = non_symbol_options.merge(new_tracks)
end

.forward_block_for_path_branch(ctx, options:, normalizer_options:, library_options:) ⇒ Object

Replace a block-expecting PathBranch instance with another one that’s holding the global :block from … do end.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/trailblazer/activity/dsl/linear/helper/path.rb', line 17

def forward_block_for_path_branch(ctx, options:, normalizer_options:, library_options:, **)
  block              = options[:block]
  non_symbol_options = options[:non_symbol_options]

  return unless block

  output, path_branch =
    non_symbol_options.find { |output, cfg| cfg.is_a?(Linear::PathBranch) }

  path_branch_with_block = Linear::PathBranch.new(
    normalizer_options
      .merge(path_branch.options)
      .merge(block: block)
  )

  ctx[:options] = ctx[:options].merge(non_symbol_options: non_symbol_options.merge(output => path_branch_with_block))
end