Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a complex example spec for Mongoid
- Loading branch information
Showing
3 changed files
with
92 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class ComplexMongoidExample | ||
include Mongoid::Document | ||
include AASM | ||
|
||
field :left, :type => String | ||
field :right, :type => String | ||
|
||
aasm :left, :column => 'left' do | ||
state :one, :initial => true | ||
state :two | ||
state :three | ||
|
||
event :increment do | ||
transitions :from => :one, :to => :two | ||
transitions :from => :two, :to => :three | ||
end | ||
event :reset do | ||
transitions :from => :three, :to => :one | ||
end | ||
end | ||
|
||
aasm :right, :column => 'right' do | ||
state :alpha, :initial => true | ||
state :beta | ||
state :gamma | ||
|
||
event :level_up do | ||
transitions :from => :alpha, :to => :beta | ||
transitions :from => :beta, :to => :gamma | ||
end | ||
event :level_down do | ||
transitions :from => :gamma, :to => :beta | ||
transitions :from => :beta, :to => :alpha | ||
end | ||
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