1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

rename aasm_persist to aasm_write_state

add aasm_read_state to complete persistence
This commit is contained in:
Scott Barron 2008-02-21 11:08:55 -05:00
parent 8c02c47160
commit 91794f70fe
2 changed files with 24 additions and 7 deletions

View file

@ -43,15 +43,20 @@ module AASM
# Instance methods
def aasm_current_state
# Persistance? This won't work for activerecord objects
@aasm_current_state || self.class.aasm_initial_state
return @aasm_current_state if @aasm_current_state
if self.respond_to?(:aasm_read_state) || self.private_methods.include?('aasm_read_state')
@aasm_current_state = aasm_read_state
end
return @aasm_read_state if @aasm_current_state
self.class.aasm_initial_state
end
private
def aasm_current_state=(state)
@aasm_current_state = state
if self.respond_to?(:aasm_persist) || self.private_methods.include?('aasm_persist')
aasm_persist
if self.respond_to?(:aasm_write_state) || self.private_methods.include?('aasm_write_state')
aasm_write_state
end
end
end