1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/spec/models/multi_transitioner.rb

35 lines
574 B
Ruby
Raw Normal View History

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