-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no need for WriteState mixin anymore (to keep adding persistence simple)
- Loading branch information
Showing
8 changed files
with
119 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,67 @@ | ||
class DefaultState | ||
attr_accessor :transient_store | ||
include AASM | ||
aasm do | ||
state :alpha, :initial => true | ||
state :beta | ||
state :gamma | ||
event :release do | ||
transitions :from => [:alpha, :beta, :gamma], :to => :beta | ||
end | ||
end | ||
end | ||
|
||
class ProvidedState | ||
attr_accessor :transient_store | ||
include AASM | ||
aasm do | ||
state :alpha, :initial => true | ||
state :beta | ||
state :gamma | ||
event :release do | ||
transitions :from => [:alpha, :beta, :gamma], :to => :beta | ||
end | ||
end | ||
|
||
def aasm_read_state | ||
:beta | ||
end | ||
|
||
def aasm_write_state(new_state) | ||
@transient_store = new_state | ||
end | ||
end | ||
|
||
class PersistedState < ActiveRecord::Base | ||
attr_accessor :transient_store | ||
include AASM | ||
aasm do | ||
state :alpha, :initial => true | ||
state :beta | ||
state :gamma | ||
event :release do | ||
transitions :from => [:alpha, :beta, :gamma], :to => :beta | ||
end | ||
end | ||
end | ||
|
||
class ProvidedAndPersistedState < ActiveRecord::Base | ||
attr_accessor :transient_store | ||
include AASM | ||
aasm do | ||
state :alpha, :initial => true | ||
state :beta | ||
state :gamma | ||
event :release do | ||
transitions :from => [:alpha, :beta, :gamma], :to => :beta | ||
end | ||
end | ||
|
||
def aasm_read_state | ||
:gamma | ||
end | ||
|
||
def aasm_write_state(new_state) | ||
@transient_store = new_state | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters