Module: Trailblazer::Activity::DSL::Helper
- Defined in:
- lib/trailblazer/activity/dsl/helper.rb
Overview
Shortcut functions for the DSL. These have no state.
Class Method Summary collapse
- .End(semantic) ⇒ Object
-
.Output(signal, semantic = nil) ⇒ Object
Output( Left, :failure ) Output( :failure ) #=> Output::Semantic.
- .Path(normalizer, track_color: "track_#{rand}", end_semantic: track_color, **options) ⇒ Object
-
.Subprocess(activity) ⇒ Object
Computes the :outputs options for activity.
- .Track(color) ⇒ Object
Class Method Details
.End(semantic) ⇒ Object
36 37 38 |
# File 'lib/trailblazer/activity/dsl/helper.rb', line 36 def End(semantic) Activity.End(semantic) end |
.Output(signal, semantic = nil) ⇒ Object
Output( Left, :failure )
Output( :failure ) #=> Output::Semantic
30 31 32 33 34 |
# File 'lib/trailblazer/activity/dsl/helper.rb', line 30 def Output(signal, semantic=nil) return OutputSemantic.new(signal) if semantic.nil? Activity.Output(signal, semantic) end |
.Path(normalizer, track_color: "track_#{rand}", end_semantic: track_color, **options) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/trailblazer/activity/dsl/helper.rb', line 44 def Path(normalizer, track_color: "track_#{rand}", end_semantic: track_color, **) = .merge(track_color: track_color, end_semantic: end_semantic) # Build an anonymous class which will be where the block is evaluated in. # We use the same normalizer here, so DSL calls in the inner block have the same behavior. path = Module.new do extend Activity::Path( .merge( normalizer: normalizer ) ) end # this block is called in DSL::ProcessTuples. This could be improved somehow. ->(block) { path.instance_exec(&block) [ track_color, path ] } end |
.Subprocess(activity) ⇒ Object
Computes the :outputs options for activity
62 63 64 65 66 67 |
# File 'lib/trailblazer/activity/dsl/helper.rb', line 62 def Subprocess(activity) { task: activity, outputs: activity.outputs } end |
.Track(color) ⇒ Object
40 41 42 |
# File 'lib/trailblazer/activity/dsl/helper.rb', line 40 def Track(color) Track.new(color).freeze end |