2012-10-26 04:52:39 -04:00
|
|
|
class Gate < ActiveRecord::Base
|
|
|
|
include AASM
|
|
|
|
|
|
|
|
# Fake this column for testing purposes
|
|
|
|
attr_accessor :aasm_state
|
|
|
|
|
|
|
|
aasm do
|
|
|
|
state :opened
|
|
|
|
state :closed
|
|
|
|
|
|
|
|
event :view do
|
|
|
|
transitions :to => :read, :from => [:needs_attention]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Reader < ActiveRecord::Base
|
2013-04-24 06:57:06 -04:00
|
|
|
include AASM
|
|
|
|
|
2012-10-26 04:52:39 -04:00
|
|
|
def aasm_read_state
|
|
|
|
"fi"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Writer < ActiveRecord::Base
|
|
|
|
def aasm_write_state(state)
|
|
|
|
"fo"
|
|
|
|
end
|
|
|
|
include AASM
|
|
|
|
end
|
|
|
|
|
|
|
|
class Transient < ActiveRecord::Base
|
|
|
|
def aasm_write_state_without_persistence(state)
|
|
|
|
"fum"
|
|
|
|
end
|
|
|
|
include AASM
|
|
|
|
end
|
|
|
|
|
|
|
|
class SimpleNewDsl < ActiveRecord::Base
|
|
|
|
include AASM
|
|
|
|
aasm :column => :status
|
|
|
|
aasm do
|
|
|
|
state :unknown_scope
|
|
|
|
state :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-06 10:55:32 -04:00
|
|
|
class NoScope < ActiveRecord::Base
|
|
|
|
include AASM
|
|
|
|
aasm :create_scopes => false do
|
2014-05-18 08:21:35 -04:00
|
|
|
state :pending, :initial => true
|
|
|
|
state :running
|
|
|
|
event :run do
|
|
|
|
transitions :from => :pending, :to => :running
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class NoDirectAssignment < ActiveRecord::Base
|
|
|
|
include AASM
|
|
|
|
aasm :no_direct_assignment => true do
|
|
|
|
state :pending, :initial => true
|
|
|
|
state :running
|
|
|
|
event :run do
|
|
|
|
transitions :from => :pending, :to => :running
|
|
|
|
end
|
2013-08-06 10:55:32 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-26 04:52:39 -04:00
|
|
|
class DerivateNewDsl < SimpleNewDsl
|
|
|
|
end
|
|
|
|
|
|
|
|
class Thief < ActiveRecord::Base
|
|
|
|
if ActiveRecord::VERSION::MAJOR >= 3
|
|
|
|
self.table_name = 'thieves'
|
|
|
|
else
|
|
|
|
set_table_name "thieves"
|
|
|
|
end
|
|
|
|
include AASM
|
2013-11-30 15:30:07 -05:00
|
|
|
aasm do
|
|
|
|
state :rich
|
|
|
|
state :jailed
|
2013-11-30 16:46:04 -05:00
|
|
|
initial_state Proc.new {|thief| thief.skilled ? :rich : :jailed }
|
2013-11-30 15:30:07 -05:00
|
|
|
end
|
2012-10-26 04:52:39 -04:00
|
|
|
attr_accessor :skilled, :aasm_state
|
|
|
|
end
|