mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
21 lines
472 B
Ruby
21 lines
472 B
Ruby
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 = []
|
|
@events = []
|
|
end
|
|
|
|
def create_state(name, options)
|
|
@states << AASM::SupportingClasses::State.new(name, options) unless @states.include?(name)
|
|
end
|
|
end
|
|
end
|