Module: StateMachine::ClassMethods
- Included in:
- Integrations::ActiveModel
- Defined in:
- lib/state_machine/extensions.rb
Class Method Summary collapse
-
.extended(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#state_machines ⇒ Object
Gets the current list of state machines defined for this class.
Class Method Details
.extended(base) ⇒ Object
:nodoc:
5 6 7 8 9 |
# File 'lib/state_machine/extensions.rb', line 5 def self.extended(base) #:nodoc: base.class_eval do @state_machines = MachineCollection.new end end |
Instance Method Details
#state_machines ⇒ Object
Gets the current list of state machines defined for this class. This class-level attribute acts like an inheritable attribute. The attribute is available to each subclass, each having a copy of its superclass’s attribute.
The hash of state machines maps :attribute
=> machine
, e.g.
Vehicle.state_machines # => {:state => #<StateMachine::Machine:0xb6f6e4a4 ...>}
19 20 21 |
# File 'lib/state_machine/extensions.rb', line 19 def state_machines @state_machines ||= superclass.state_machines.dup end |