Module: StateMachines::ClassMethods
- Defined in:
- lib/state_machines/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:
3 4 5 6 7 |
# File 'lib/state_machines/extensions.rb', line 3 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 => #<StateMachines::Machine:0xb6f6e4a4 ...>}
17 18 19 |
# File 'lib/state_machines/extensions.rb', line 17 def state_machines @state_machines ||= superclass.state_machines.dup end |