mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
5739f92219
@PragTob's suggestion from https://github.com/aasm/aasm/issues/262.
31 lines
791 B
Ruby
31 lines
791 B
Ruby
require 'active_record'
|
|
|
|
class SilentPersistor < ActiveRecord::Base
|
|
include AASM
|
|
aasm :column => :status, :whiny_persistence => false do
|
|
state :sleeping, :initial => true
|
|
state :running
|
|
event :run do
|
|
transitions :to => :running, :from => :sleeping
|
|
end
|
|
event :sleep do
|
|
transitions :to => :sleeping, :from => :running
|
|
end
|
|
end
|
|
validates_presence_of :name
|
|
end
|
|
|
|
class MultipleSilentPersistor < ActiveRecord::Base
|
|
include AASM
|
|
aasm :left, :column => :status, :whiny_persistence => false do
|
|
state :sleeping, :initial => true
|
|
state :running
|
|
event :run do
|
|
transitions :to => :running, :from => :sleeping
|
|
end
|
|
event :sleep do
|
|
transitions :to => :sleeping, :from => :running
|
|
end
|
|
end
|
|
validates_presence_of :name
|
|
end
|