mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
46 lines
607 B
Ruby
46 lines
607 B
Ruby
class SuperClass
|
|
include AASM
|
|
|
|
aasm do
|
|
state :read
|
|
state :ended
|
|
|
|
event :foo do
|
|
transitions :to => :ended, :from => [:read]
|
|
end
|
|
end
|
|
|
|
def update_state
|
|
if may_foo?
|
|
foo!
|
|
end
|
|
end
|
|
end
|
|
|
|
class SuperClassMultiple
|
|
include AASM
|
|
|
|
aasm(:left) do
|
|
state :read
|
|
state :ended
|
|
|
|
event :foo do
|
|
transitions :to => :ended, :from => [:read]
|
|
end
|
|
end
|
|
|
|
aasm(:right) do
|
|
state :opened
|
|
state :closed
|
|
|
|
event :close do
|
|
transitions :to => :closed, :from => [:opened]
|
|
end
|
|
end
|
|
|
|
def update_state
|
|
if may_foo?
|
|
foo!
|
|
end
|
|
end
|
|
end
|