Module: AASM

Defined in:
lib/aasm/aasm.rb,
lib/aasm/base.rb,
lib/aasm/errors.rb,
lib/aasm/version.rb,
lib/aasm/localizer.rb,
lib/aasm/dsl_helper.rb,
lib/aasm/persistence.rb,
lib/aasm/core/invoker.rb,
lib/aasm/configuration.rb,
lib/aasm/instance_base.rb,
lib/aasm/state_machine.rb,
lib/aasm/persistence/orm.rb,
lib/aasm/persistence/base.rb,
lib/aasm/state_machine_store.rb,
lib/generators/aasm/orm_helpers.rb,
lib/generators/aasm/aasm_generator.rb,
lib/aasm/core/invokers/base_invoker.rb,
lib/aasm/core/invokers/proc_invoker.rb,
lib/aasm/core/invokers/class_invoker.rb,
lib/aasm/core/invokers/literal_invoker.rb,
lib/aasm/persistence/plain_persistence.rb,
lib/aasm/persistence/redis_persistence.rb,
lib/aasm/persistence/sequel_persistence.rb,
lib/aasm/persistence/mongoid_persistence.rb,
lib/aasm/persistence/dynamoid_persistence.rb,
lib/aasm/persistence/no_brainer_persistence.rb,
lib/aasm/persistence/active_record_persistence.rb,
lib/aasm/persistence/core_data_query_persistence.rb

Defined Under Namespace

Modules: ClassMethods, Core, DslHelper, Generators, Persistence Classes: Base, Configuration, InstanceBase, InvalidTransition, Localizer, NoDirectAssignmentError, StateMachine, StateMachineStore, UndefinedEvent, UndefinedState, UnknownStateMachineError

Constant Summary collapse

NO_VALUE =

this is used internally as an argument default value to represent no value

:_aasm_no_value
VERSION =
"5.5.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

provide a state machine for the including class make sure to load class methods as well initialize persistence for the state machine



8
9
10
11
12
13
14
15
16
17
# File 'lib/aasm/aasm.rb', line 8

def self.included(base) #:nodoc:
  base.extend AASM::ClassMethods

  # do not overwrite existing state machines, which could have been created by
  # inheritance, see class method inherited
  AASM::StateMachineStore.register(base)

  AASM::Persistence.load_persistence(base)
  super
end

Instance Method Details

#aasm(name = :default) ⇒ Object

this is the entry point for all instance-level access to AASM



68
69
70
71
72
73
74
# File 'lib/aasm/aasm.rb', line 68

def aasm(name=:default)
  unless AASM::StateMachineStore.fetch(self.class, true).machine(name)
    raise AASM::UnknownStateMachineError.new("There is no state machine with the name '#{name}' defined in #{self.class.name}!")
  end
  @aasm ||= Concurrent::Map.new
  @aasm[name.to_sym] ||= AASM::InstanceBase.new(self, name.to_sym)
end

#initialize_dup(other) ⇒ Object



76
77
78
79
# File 'lib/aasm/aasm.rb', line 76

def initialize_dup(other)
  @aasm = Concurrent::Map.new
  super
end