2011-09-16 10:57:23 -04:00
|
|
|
class Foo
|
|
|
|
include AASM
|
2011-11-26 15:11:57 -05:00
|
|
|
aasm do
|
2014-09-09 17:02:11 -04:00
|
|
|
state :open, :initial => true, :before_exit => :before_exit
|
|
|
|
state :closed, :before_enter => :before_enter
|
2014-07-12 09:24:10 -04:00
|
|
|
state :final
|
2011-09-16 10:57:23 -04:00
|
|
|
|
2011-11-26 15:11:57 -05:00
|
|
|
event :close, :success => :success_callback do
|
2013-04-28 11:46:16 -04:00
|
|
|
transitions :from => [:open], :to => [:closed]
|
2011-11-26 15:11:57 -05:00
|
|
|
end
|
2011-09-16 10:57:23 -04:00
|
|
|
|
2011-11-26 15:11:57 -05:00
|
|
|
event :null do
|
2014-07-12 09:24:10 -04:00
|
|
|
transitions :from => [:open], :to => [:closed, :final], :guard => :always_false
|
2011-11-26 15:11:57 -05:00
|
|
|
end
|
2011-09-16 10:57:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def always_false
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def success_callback
|
|
|
|
end
|
|
|
|
|
2014-09-09 17:02:11 -04:00
|
|
|
def before_enter
|
2011-09-16 10:57:23 -04:00
|
|
|
end
|
2014-09-09 17:02:11 -04:00
|
|
|
def before_exit
|
2011-09-16 10:57:23 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class FooTwo < Foo
|
|
|
|
include AASM
|
2011-11-26 15:11:57 -05:00
|
|
|
aasm do
|
|
|
|
state :foo
|
|
|
|
end
|
2011-09-16 10:57:23 -04:00
|
|
|
end
|
2015-06-26 03:46:58 -04:00
|
|
|
|
|
|
|
class FooMultiple
|
|
|
|
include AASM
|
|
|
|
|
|
|
|
aasm(:left) do
|
|
|
|
state :open, :initial => true, :before_exit => :before_exit
|
|
|
|
state :closed, :before_enter => :before_enter
|
|
|
|
state :final
|
|
|
|
|
|
|
|
event :close, :success => :success_callback do
|
|
|
|
transitions :from => [:open], :to => [:closed]
|
|
|
|
end
|
|
|
|
|
|
|
|
event :null do
|
|
|
|
transitions :from => [:open], :to => [:closed, :final], :guard => :always_false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
aasm(:right, :column => :right) do
|
|
|
|
state :green, :initial => true
|
|
|
|
state :yellow
|
|
|
|
state :red
|
|
|
|
|
|
|
|
event :green do
|
|
|
|
transitions :from => [:yellow], :to => :green
|
|
|
|
end
|
|
|
|
event :yellow do
|
|
|
|
transitions :from => [:green, :red], :to => :yellow
|
|
|
|
end
|
|
|
|
event :red do
|
|
|
|
transitions :from => [:yellow], :to => :red
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def always_false
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def success_callback
|
|
|
|
end
|
|
|
|
|
|
|
|
def before_enter
|
|
|
|
end
|
|
|
|
def before_exit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class FooTwoMultiple < FooMultiple
|
|
|
|
include AASM
|
|
|
|
aasm(:left) do
|
|
|
|
state :foo
|
|
|
|
end
|
|
|
|
|
|
|
|
aasm(:right) do
|
|
|
|
state :bar
|
|
|
|
end
|
|
|
|
end
|