Class: Trailblazer::Activity::DSL::Linear::Strategy
- Inherits:
-
Object
- Object
- Trailblazer::Activity::DSL::Linear::Strategy
- Extended by:
- Helper, Merge::DSL
- Includes:
- Helper::Constants
- Defined in:
- lib/trailblazer/activity/dsl/linear/strategy.rb
Overview
holds the {@schema}
provides DSL step/merge!
provides DSL inheritance
provides run-time {call}
maintains the {state} with {seq} and normalizer
This could be a class but we decided to leave it as a module that then gets extended into Helper::Path and friends. This won’t trigger the inheritance (because) there is nothing to inherit.
Defined Under Namespace
Modules: DSL
Class Method Summary collapse
-
.call(args, **circuit_options) ⇒ Object
Injects :exec_context so that :instance_methods work.
-
.compile_strategy!(strategy_dsl, **options) ⇒ Object
Used only once per strategy class body.
- .compile_strategy_for!(sequence:, normalizers:, **normalizer_options) ⇒ Object
-
.copy(value) ⇒ Object
FIXME: move to State#dup.
- .inherited(inheriter) ⇒ Object
- .initialize!(state) ⇒ Object
- .invoke(*args, **kws) ⇒ Object
-
.recompile!(sequence) ⇒ Object
DISCUSS: this should be the only way to “update” anything on state.
-
.step(*args, &block) ⇒ Object
We forward ‘step` to the Dsl (State) object.
- .terminus(*args) ⇒ Object
-
.to_h ⇒ Object
Mainly used for introspection.
Methods included from Helper
DataVariable, End, Extension, Id, In, Inject, Out, Output, Path, Subprocess, Track, end_id
Methods included from Merge::DSL
Class Method Details
.call(args, **circuit_options) ⇒ Object
Injects :exec_context so that :instance_methods work.
103 104 105 106 107 108 109 110 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 103 def call(args, **) activity = @state.get(:activity) activity.( args, **.merge(exec_context: new) ) end |
.compile_strategy!(strategy_dsl, **options) ⇒ Object
Used only once per strategy class body.
78 79 80 81 82 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 78 def compile_strategy!(strategy_dsl, **) = DSL.OptionsForSequenceBuilder(strategy_dsl, **) compile_strategy_for!(**) end |
.compile_strategy_for!(sequence:, normalizers:, **normalizer_options) ⇒ Object
84 85 86 87 88 89 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 84 def compile_strategy_for!(sequence:, normalizers:, **) @state.update!(:normalizers) { normalizers } # immutable @state.update!(:normalizer_options) { } # immutable recompile!(sequence) end |
.copy(value) ⇒ Object
FIXME: move to State#dup
174 175 176 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 174 def self.copy(value, **) # DISCUSS: should that be here? value.copy end |
.inherited(inheriter) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 23 def inherited(inheriter) super # Inherits the {State:sequencer} and other options without recomputing anything. inheriter.initialize!(@state.copy) end |
.initialize!(state) ⇒ Object
19 20 21 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 19 def initialize!(state) @state = state end |
.invoke(*args, **kws) ⇒ Object
112 113 114 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 112 def invoke(*args, **kws) TaskWrap.invoke(self, *args, **kws) end |
.recompile!(sequence) ⇒ Object
DISCUSS: this should be the only way to “update” anything on state.
70 71 72 73 74 75 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 70 def recompile!(sequence) activity = recompile_activity(sequence) @state.update!(:sequence) { |*| sequence } @state.update!(:activity) { |*| activity } end |
.step(*args, &block) ⇒ Object
We forward ‘step` to the Dsl (State) object. Recompiling the activity/sequence is a matter specific to Strategy (Railway etc).
33 34 35 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 33 def step(*args, &block) recompile_activity_for(:step, *args, &block) end |
.terminus(*args) ⇒ Object
37 38 39 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 37 def terminus(*args) recompile_activity_for(:terminus, *args) end |
.to_h ⇒ Object
Mainly used for introspection.
92 93 94 95 96 97 98 99 |
# File 'lib/trailblazer/activity/dsl/linear/strategy.rb', line 92 def to_h activity = @state.get(:activity) activity.to_h.to_h.merge( activity: activity, sequence: @state.get(:sequence) ) end |