class
FSM::Transition(T)
- FSM::Transition(T)
- Reference
- Object
Overview
A transition from one state to another on an event.
Transition(T) is a class, not a struct, with the same lifecycle as
StateDefinition: the builder creates it, mutates it during build via #on and
#guard, and it is read-only forever afterward while shared across every
interpreter. Making it a class means the builder mutates one shared object
rather than a copy, which is why registering a guard and a callback on the
yielded transition takes effect. #event and #target are
set at construction and never change; the only mutable surface is #on and
#guard, which raise SealedStateError once the machine seals it.
Defined in:
fsm/transition.crInstance Method Summary
- #event : String
-
#guard(&block : String, T -> Bool) : self
Register the guard predicate that must return true for this transition to be selected.
-
#internal : self
Mark this transition internal.
-
#on(&block : String, T -> ) : self
Register the transition callback fired during the transition.
- #target : String
Instance Method Detail
Register the guard predicate that must return true for this transition to be selected.
Mark this transition internal. Chainable, so it reads as
t.internal.on { ... }. Raises once sealed, like #on and #guard, because
the internal flag is definition state and sealing means what you built is what
runs.
Register the transition callback fired during the transition.