mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
924585f2dd
does not have a "from" parameter
34 lines
574 B
Ruby
34 lines
574 B
Ruby
class MultiTransitioner
|
|
include AASM
|
|
|
|
attr_accessor :can_run
|
|
|
|
def initialize
|
|
@can_run = false
|
|
end
|
|
|
|
aasm do
|
|
state :sleeping, :initial => true
|
|
state :running
|
|
state :dancing
|
|
state :dead
|
|
|
|
event :start do
|
|
transitions :from => :sleeping, :to => :running, guard: :runnable?
|
|
transitions :from => :sleeping, :to => :dancing
|
|
end
|
|
|
|
event :sleep do
|
|
transitions to: :sleeping, if: :alive?
|
|
transitions to: :dead, from: [:running, :dancing]
|
|
end
|
|
end
|
|
|
|
def runnable?
|
|
@can_run
|
|
end
|
|
|
|
def alive?
|
|
true
|
|
end
|
|
end
|