Class: Trailblazer::Activity::DSL::Linear::State::Normalizer
- Inherits:
-
Object
- Object
- Trailblazer::Activity::DSL::Linear::State::Normalizer
- Defined in:
- lib/trailblazer/activity/dsl/linear/state.rb
Overview
Compiles and maintains all final normalizers for a specific DSL.
Instance Method Summary collapse
-
#call(name, *args) ⇒ Object
Execute the specific normalizer (step, fail, pass) for a particular option set provided by the DSL user.
- #compile_normalizer(normalizer_sequence) ⇒ Object
-
#initialize(normalizer_sequences) ⇒ Normalizer
constructor
[gets instantiated at compile time.].
Constructor Details
#initialize(normalizer_sequences) ⇒ Normalizer
- gets instantiated at compile time.
-
We simply compile the activities that represent the normalizers for #step, #pass, etc. This can happen at compile-time, as normalizers are stateless.
51 52 53 54 55 |
# File 'lib/trailblazer/activity/dsl/linear/state.rb', line 51 def initialize(normalizer_sequences) @normalizers = Hash[ normalizer_sequences.collect { |name, seq| [name, compile_normalizer(seq)] } ] end |
Instance Method Details
#call(name, *args) ⇒ Object
Execute the specific normalizer (step, fail, pass) for a particular option set provided by the DSL user. This is usually when you call Operation::step.
59 60 61 62 63 |
# File 'lib/trailblazer/activity/dsl/linear/state.rb', line 59 def call(name, *args) normalizer = @normalizers.fetch(name) signal, (, _) = normalizer.(*args) end |
#compile_normalizer(normalizer_sequence) ⇒ Object
42 43 44 45 |
# File 'lib/trailblazer/activity/dsl/linear/state.rb', line 42 def compile_normalizer(normalizer_sequence) process = Trailblazer::Activity::DSL::Linear::Compiler.(normalizer_sequence) process.to_h[:circuit] end |