mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00

Permitted states now returns the correct states when an event has more than one transition, and if a transition uses a guard.
24 lines
399 B
Ruby
24 lines
399 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
|
|
|
|
event :start do
|
|
transitions :from => :sleeping, :to => :running, guard: :runnable?
|
|
transitions :from => :sleeping, :to => :dancing
|
|
end
|
|
end
|
|
|
|
def runnable?
|
|
@can_run
|
|
end
|
|
end
|