2008-05-31 22:27:15 +00:00
|
|
|
module AASM
|
|
|
|
unless AASM.const_defined?('StateMachineFactory')
|
|
|
|
StateMachineFactory = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
class StateMachine
|
|
|
|
attr_accessor :states, :events, :initial_state
|
|
|
|
attr_reader :name
|
|
|
|
|
|
|
|
def initialize(name)
|
|
|
|
@name = name
|
|
|
|
@initial_state = nil
|
|
|
|
@states = []
|
2008-05-31 22:37:22 +00:00
|
|
|
@events = {}
|
2008-05-31 22:27:15 +00:00
|
|
|
end
|
2008-05-31 22:33:17 +00:00
|
|
|
|
|
|
|
def create_state(name, options)
|
|
|
|
@states << AASM::SupportingClasses::State.new(name, options) unless @states.include?(name)
|
|
|
|
end
|
2008-05-31 22:27:15 +00:00
|
|
|
end
|
|
|
|
end
|