mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
712a144966
* add binding_event * Add specs for binding_event
42 lines
961 B
Ruby
42 lines
961 B
Ruby
class SimpleMultipleExample
|
|
include AASM
|
|
aasm(:move) do
|
|
state :standing, :initial => true
|
|
state :walking
|
|
state :running
|
|
|
|
event :walk do
|
|
transitions :from => :standing, :to => :walking
|
|
end
|
|
event :run do
|
|
transitions :from => [:standing, :walking], :to => :running
|
|
end
|
|
event :hold do
|
|
transitions :from => [:walking, :running], :to => :standing
|
|
end
|
|
end
|
|
|
|
aasm(:work) do
|
|
state :sleeping, :initial => true
|
|
state :processing
|
|
|
|
event :start do
|
|
transitions :from => :sleeping, :to => :processing
|
|
end
|
|
event :stop do
|
|
transitions :from => :processing, :to => :sleeping
|
|
end
|
|
end
|
|
|
|
aasm(:question) do
|
|
state :answered, :initial => true
|
|
state :asked
|
|
|
|
event :ask, :binding_event => :start do
|
|
transitions :from => :answered, :to => :asked
|
|
end
|
|
event :answer, :binding_event => :stop do
|
|
transitions :from => :asked, :to => :answered
|
|
end
|
|
end
|
|
end
|