class Trailblazer::Activity::DSL::Linear::State
A {State} instance is kept per DSL
client, which usually is a subclass of {Path}, {Railway}, etc. State
doesn't have any immutable features - all write operations to it must guarantee they only replace instance variables.
@private
DISCUSS: why do we have this structure? It doesn't cover “immutable copying”, that has to be done by its clients.
also, copy with to_h
Public Class Methods
new(normalizers:, initial_sequence:, fields: {}.freeze, **normalizer_options)
click to toggle source
remembers how to call normalizers (e.g. track_color), TaskBuilder remembers sequence
# File lib/trailblazer/activity/dsl/linear/state.rb, line 16 def initialize(normalizers:, initial_sequence:, fields: {}.freeze, **normalizer_options) @normalizer = normalizers # compiled normalizers. @sequence = initial_sequence @normalizer_options = normalizer_options @fields = fields end
Public Instance Methods
copy()
click to toggle source
Called to “inherit” a state.
# File lib/trailblazer/activity/dsl/linear/state.rb, line 24 def copy self.class.new(normalizers: @normalizer, initial_sequence: @sequence, fields: @fields, **@normalizer_options) end
to_h()
click to toggle source
# File lib/trailblazer/activity/dsl/linear/state.rb, line 28 def to_h {sequence: @sequence, normalizers: @normalizer, normalizer_options: @normalizer_options, fields: @fields} # FIXME. end
update_options(fields)
click to toggle source
# File lib/trailblazer/activity/dsl/linear/state.rb, line 36 def update_options(fields) @fields = fields end
update_sequence() { |**to_h| ... }
click to toggle source
# File lib/trailblazer/activity/dsl/linear/state.rb, line 32 def update_sequence(&block) @sequence = yield(**to_h) end