The starting point for building instances of Statemachine. The block passed in should contain all the declarations for all states, events, and actions with in the statemachine.
Sample: Turnstyle
sm = Statemachine.build do trans :locked, :coin, :unlocked, :unlock trans :unlocked, :pass, :locked, :lock end
An optional statemachine paramter may be passed in to modify an existing statemachine instance.
Actions: Where ever an action paramter is used, it may take on one of three forms:
1. Symbols: will execute a method by the same name on the _context_ 2. String: Ruby code that will be executed within the binding of the _context_ 3. Proc: Will be executed within the binding of the _context_
See Statemachine::SuperstateBuilding See Statemachine::StateBuilding
# File lib/statemachine/builder.rb, line 26 26: def self.build(statemachine = nil, &block) 27: builder = statemachine ? StatemachineBuilder.new(statemachine) : StatemachineBuilder.new 28: builder.instance_eval(&block) 29: builder.statemachine.reset 30: return builder.statemachine 31: end