Class: Trailblazer::Activity::DSL::Linear::State

Inherits:
Object
  • Object
show all
Defined in:
lib/trailblazer/activity/dsl/linear/state.rb

Overview

A State instance is kept per DSL client, which usually is a subclass of Path, Railway, etc.

Defined Under Namespace

Classes: Normalizer

Instance Method Summary collapse

Constructor Details

#initialize(normalizers:, initial_sequence:, **normalizer_options) ⇒ State

remembers how to call normalizers (e.g. track_color), TaskBuilder remembers sequence



9
10
11
12
13
# File 'lib/trailblazer/activity/dsl/linear/state.rb', line 9

def initialize(normalizers:, initial_sequence:, **normalizer_options)
  @normalizer         = normalizers # compiled normalizers.
  @sequence           = initial_sequence
  @normalizer_options = normalizer_options
end

Instance Method Details

#copyObject

Called to “inherit” a state.



16
17
18
# File 'lib/trailblazer/activity/dsl/linear/state.rb', line 16

def copy
  self.class.new(normalizers: @normalizer, initial_sequence: @sequence, **@normalizer_options)
end

#to_hObject



20
21
22
# File 'lib/trailblazer/activity/dsl/linear/state.rb', line 20

def to_h
  {sequence: @sequence, normalizers: @normalizer, normalizer_options: @normalizer_options} # FIXME.
end

#update_sequence(&block) ⇒ Object



24
25
26
# File 'lib/trailblazer/activity/dsl/linear/state.rb', line 24

def update_sequence(&block)
  @sequence = yield(to_h)
end