2011-10-16 15:13:25 -04:00
|
|
|
class ProcessWithNewDsl
|
|
|
|
include AASM
|
|
|
|
|
|
|
|
def self.state(*args)
|
|
|
|
raise "wrong state method"
|
|
|
|
end
|
|
|
|
|
2011-11-25 17:55:56 -05:00
|
|
|
attr_accessor :flagged
|
|
|
|
|
2011-10-16 15:13:25 -04:00
|
|
|
aasm do
|
|
|
|
state :sleeping, :initial => true
|
2011-11-25 17:55:56 -05:00
|
|
|
state :running, :after_enter => :flag
|
2011-10-16 15:13:25 -04:00
|
|
|
state :suspended
|
|
|
|
|
|
|
|
event :start do
|
|
|
|
transitions :from => :sleeping, :to => :running
|
|
|
|
end
|
|
|
|
event :stop do
|
|
|
|
transitions :from => :running, :to => :suspended
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-25 17:55:56 -05:00
|
|
|
def flag
|
|
|
|
self.flagged = true
|
|
|
|
end
|
|
|
|
|
2011-10-16 15:13:25 -04:00
|
|
|
def self.event(*args)
|
|
|
|
raise "wrong event method"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|