Sha256: 687451321205ee1d0cd5c394c2354d28895c9be279f0e3ca212a865b8743636a
Contents?: true
Size: 911 Bytes
Versions: 5
Compression:
Stored size: 911 Bytes
Contents
module EdgeStateMachine class Machine attr_accessor :states, :events, :klass, :persisted_variable_name attr_reader :name, :initial_state_name def initialize(klass, name, &block) @klass = klass @name = name @states = Hash.new @events = Hash.new instance_eval(&block) if block_given? end def initial_state(name) @initial_state_name = name end def persisted_to(name) @persisted_variable_name = name end def create_scopes(bool = false) @create_scopes = bool end def create_scopes? @create_scopes end def state(name, &state) state = EdgeStateMachine::State.new(name, &state) @initial_state_name ||= state.name @states[name.to_sym] = state end def event(name, &transitions) @events[name.to_sym] ||= EdgeStateMachine::Event.new(name, self, &transitions) end end end
Version data entries
5 entries across 5 versions & 1 rubygems