Module: AASM::Persistence::MongoidPersistence::ClassMethods

Defined in:
lib/aasm/persistence/mongoid_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 Mongoid::Document
  include AASM
  field :aasm_state
end

OR:

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

This method is both a getter and a setter



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/aasm/persistence/mongoid_persistence.rb', line 80

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