class AASM::Base
def initialize(klass, name, state_machine, options={}, &block)
def initialize(klass, name, state_machine, options={}, &block) @klass = klass @name = name # @state_machine = klass.aasm(@name).state_machine @state_machine = state_machine @state_machine.config.column ||= (options[:column] || default_column).to_sym # @state_machine.config.column = options[:column].to_sym if options[:column] # master @options = options # let's cry if the transition is invalid configure :whiny_transitions, true # create named scopes for each state configure :create_scopes, true # don't store any new state if the model is invalid (in ActiveRecord) configure :skip_validation_on_save, false # raise if the model is invalid (in ActiveRecord) configure :whiny_persistence, false # Use transactions (in ActiveRecord) configure :use_transactions, true # use requires_new for nested transactions (in ActiveRecord) configure :requires_new_transaction, true # use pessimistic locking (in ActiveRecord) # true for FOR UPDATE lock # string for a specific lock type i.e. FOR UPDATE NOWAIT configure :requires_lock, false # automatically set `"#{state_name}_at" = ::Time.now` on state changes configure :timestamps, false # set to true to forbid direct assignment of aasm_state column (in ActiveRecord) configure :no_direct_assignment, false # allow a AASM::Base sub-class to be used for state machine configure :with_klass, AASM::Base configure :enum, nil # Set to true to namespace reader methods and constants configure :namespace, false # Configure a logger, with default being a Logger to STDERR configure :logger, Logger.new(STDERR) # setup timestamp-setting callback if enabled setup_timestamps(@name) # make sure to raise an error if no_direct_assignment is enabled # and attribute is directly assigned though setup_no_direct_assignment(@name) end