1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/spec/functional/conversation.rb
Jeff Dean cb6bd4f534 * Specs and bug fixes for the ActiveRecordPersistence, keeping persistence columns in sync
Allowing for nil values in states for active record
  New non-(!) methods that allow for firing events without persisting [Jeff Dean]
2008-04-29 01:27:56 -04:00

49 lines
828 B
Ruby

require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'aasm')
class Conversation
include AASM
aasm_initial_state :needs_attention
aasm_state :needs_attention
aasm_state :read
aasm_state :closed
aasm_state :awaiting_response
aasm_state :junk
aasm_event :new_message do
end
aasm_event :view do
transitions :to => :read, :from => [:needs_attention]
end
aasm_event :reply do
end
aasm_event :close do
transitions :to => :closed, :from => [:read, :awaiting_response]
end
aasm_event :junk do
transitions :to => :junk, :from => [:read]
end
aasm_event :unjunk do
end
def initialize(persister)
@persister = persister
end
private
def aasm_read_state
@persister.read_state
end
def aasm_write_state(state)
@persister.write_state(state)
end
end