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
Ebrahim Kobeissi 2449fcc165 Fixes incorrect permitted states
Permitted states now returns the correct states when an event has more than one transition, and if a transition uses a guard.
2016-01-13 17:43:22 -05:00

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