Module: AASM::Persistence::MongoMapperPersistence::ClassMethods

Defined in:
lib/aasm/persistence/mongo_mapper_persistence.rb

Instance Method Summary collapse

Instance Method Details

#aasm_column(column_name = nil) ⇒ Object

Maps to the aasm_column in the database. Deafults to “aasm_state”. You can write:

class Foo
  include MongoMapper::Document
  include AASM
  field :aasm_state
end

OR:

class Foo
  include MongoMapper::Document
  include AASM
  field :status
  aasm_column :status
end

This method is both a getter and a setter



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/aasm/persistence/mongo_mapper_persistence.rb', line 67

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