Class: Statecraft::Machine::Compiler
- Inherits:
-
Object
- Object
- Statecraft::Machine::Compiler
- Defined in:
- lib/statecraft/machine.rb
Overview
Validates the declarations and produces the deep-frozen graph. All five compilation errors live here, plus symbol resolution: every Symbol guard or callback must exist as an instance method of the machine class at finalization time (never checked at the declaration line, so a guard may be declared above its def).
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(machine_class) ⇒ Compiler
constructor
A new instance of Compiler.
Constructor Details
#initialize(machine_class) ⇒ Compiler
Returns a new instance of Compiler.
189 190 191 |
# File 'lib/statecraft/machine.rb', line 189 def initialize(machine_class) @machine_class = machine_class end |
Instance Method Details
#compile ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/statecraft/machine.rb', line 193 def compile states = compile_states initial = compile_initial(states) edges = compile_edges(states) events = compile_events(edges) resolve_symbols(edges) assert_record_guards_unary(edges) CompiledGraph.new( states: states.freeze, initial_state: initial, edges: deep_freeze_edges(edges), events: freeze_events(events), callbacks: freeze_callbacks ).freeze end |