Module: Urge::Persistence::Base::ClassMethods
- Defined in:
- lib/urge/persistence/base.rb
Instance Method Summary collapse
-
#persist_class_method ⇒ Object
Maps to the aasm_column in the database.
Instance Method Details
#persist_class_method ⇒ Object
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.config.column = column_name.to_sym # @aasm_column = column_name.to_sym else AASM::StateMachine.config.column ||= :aasm_state # @aasm_column ||= :aasm_state end
@aasm_column
AASM::StateMachine.config.column end
44 45 46 |
# File 'lib/urge/persistence/base.rb', line 44 def persist_class_method "This is Base::persist_class_method" end |