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/persistence.rb,
lib/aasm/configuration.rb,
lib/aasm/instance_base.rb,
lib/aasm/state_machine.rb,
lib/aasm/persistence/base.rb,
lib/aasm/persistence/plain_persistence.rb,
lib/aasm/persistence/sequel_persistence.rb,
lib/aasm/persistence/mongoid_persistence.rb,
lib/aasm/persistence/mongo_mapper_persistence.rb,
lib/aasm/persistence/active_record_persistence.rb
Defined Under Namespace
Modules: ClassMethods, Core, Persistence Classes: Base, Configuration, InstanceBase, InvalidTransition, Localizer, NoDirectAssignmentError, StateMachine, UndefinedState, UnknownStateMachineError
Constant Summary collapse
- VERSION =
"4.5.2"
Class Method Summary collapse
-
.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.
Instance Method Summary collapse
-
#aasm(name = :default) ⇒ Object
this is the entry point for all instance-level access to AASM.
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
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/aasm/aasm.rb', line 6 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::StateMachine[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
62 63 64 65 66 67 68 |
# File 'lib/aasm/aasm.rb', line 62 def aasm(name=:default) unless AASM::StateMachine[self.class][name.to_sym] raise AASM::UnknownStateMachineError.new("There is no state machine with the name '#{name}' defined in #{self.class.name}!") end @aasm ||= {} @aasm[name.to_sym] ||= AASM::InstanceBase.new(self, name.to_sym) end |