Module: Trailblazer::Activity::DSL::Linear::Helper

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

Overview

Shortcut functions for the DSL. Those are included in Strategy so they’re available to all Strategy users such as Railway or Operation.

Defined Under Namespace

Modules: Constants, Path

Instance Method Summary collapse

Instance Method Details

#DataVariableObject



93
94
95
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 93

def DataVariable
  DataVariableName.new
end

#End(semantic) ⇒ Object



33
34
35
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 33

def End(semantic)
  Normalizer::OutputTuples::End.new(semantic).freeze
end

#end_id(semantic:) ⇒ Object



37
38
39
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 37

def end_id(semantic:, **)
  "End.#{semantic}" # TODO: use everywhere
end

#Extension(*args, **kws) ⇒ Object



89
90
91
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 89

def Extension(*args, **kws)
  Normalizer::Extensions.Extension(*args, **kws)
end

#Id(id) ⇒ Object



45
46
47
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 45

def Id(id)
  Normalizer::OutputTuples::Id.new(id).freeze
end

#In(**kws) ⇒ Object



77
78
79
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 77

def In(**kws)
  VariableMapping::DSL::In(**kws)
end

#Inject(*args, **kws) ⇒ Object



85
86
87
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 85

def Inject(*args, **kws)
  VariableMapping::DSL::Inject(*args, **kws)
end

#Out(**kws) ⇒ Object



81
82
83
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 81

def Out(**kws)
  VariableMapping::DSL::Out(**kws)
end

#Output(signal, semantic = nil) ⇒ Object

Output( Left, :failure )

Output( :failure ) #=> Output::Semantic


27
28
29
30
31
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 27

def Output(signal, semantic = nil)
  return Normalizer::OutputTuples::Output::Semantic.new(signal) if semantic.nil?

  Normalizer::OutputTuples::Output::CustomOutput.new(signal, semantic)
end

#Path(**options, &block) ⇒ Object



49
50
51
52
53
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 49

def Path(**options, &block)
  options = options.merge(block: block) if block

  Linear::PathBranch.new(options) # picked up by normalizer.
end

#Subprocess(activity, patch: {}, strict: false) ⇒ Object

Computes the :outputs options for activity.

Parameters:

  • :strict

    If true, all outputs of activity will be wired to the track named after the output’s semantic.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 58

def Subprocess(activity, patch: {}, strict: false)
  activity = Linear::Patch.customize(activity, options: patch)

  outputs  = activity.to_h[:outputs]
  options  = {}

  if strict
    options.merge!(
      outputs.collect { |output| [Normalizer::OutputTuples::Output::Semantic.new(output.semantic, true), Track(output.semantic)] }.to_h
    )
  end

  {
    task:    activity,
    outputs: outputs.collect { |output| [output.semantic, output] }.to_h,
  }
    .merge(options)
end

#Track(color, wrap_around: false) ⇒ Object



41
42
43
# File 'lib/trailblazer/activity/dsl/linear/helper.rb', line 41

def Track(color, wrap_around: false)
  Normalizer::OutputTuples::Track.new(color, [], wrap_around: wrap_around).freeze
end