-
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.
- Loading branch information
Showing
4 changed files
with
49 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module AASM | ||
module Persistence | ||
module Base | ||
|
||
module ClassMethods | ||
# Maps to the aasm_column in the database. Defaults to "aasm_state". You can write | ||
# (example provided here for ActiveRecord, but it's true for Mongoid as well): | ||
# | ||
# create_table :foos do |t| | ||
# t.string :name | ||
# t.string :aasm_state | ||
# end | ||
# | ||
# class Foo < ActiveRecord::Base | ||
# include AASM | ||
# end | ||
# | ||
# OR: | ||
# | ||
# create_table :foos do |t| | ||
# t.string :name | ||
# t.string :status | ||
# end | ||
# | ||
# class Foo < ActiveRecord::Base | ||
# include AASM | ||
# aasm_column :status | ||
# end | ||
# | ||
# This method is both a getter and a setter | ||
def aasm_column(column_name=nil) | ||
if column_name | ||
AASM::StateMachine[self].config.column = column_name.to_sym | ||
# @aasm_column = column_name.to_sym | ||
else | ||
AASM::StateMachine[self].config.column ||= :aasm_state | ||
# @aasm_column ||= :aasm_state | ||
end | ||
# @aasm_column | ||
AASM::StateMachine[self].config.column | ||
end | ||
end | ||
|
||
end # Base | ||
end # Persistence | ||
end # AASM |
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