Module: Finity::ClassMethods
- Defined in:
- lib/finity.rb
Overview
Class methods to be injected into the including class upon inclusion.
Instance Attribute Summary collapse
-
#machine ⇒ Object
Returns the value of attribute machine.
Instance Method Summary collapse
-
#events ⇒ Object
Return the names of all registered events.
-
#finity(options = {}, &block) ⇒ Object
Instantiate a new state machine for the including class by accepting a block with state and event (and subsequent transition) definitions.
-
#states ⇒ Object
Return the names of all registered states.
Instance Attribute Details
#machine ⇒ Object
Returns the value of attribute machine.
36 37 38 |
# File 'lib/finity.rb', line 36 def machine @machine end |
Instance Method Details
#events ⇒ Object
Return the names of all registered events.
50 51 52 |
# File 'lib/finity.rb', line 50 def events @machine.events.map { |name, _| name } end |
#finity(options = {}, &block) ⇒ Object
Instantiate a new state machine for the including class by accepting a block with state and event (and subsequent transition) definitions.
40 41 42 |
# File 'lib/finity.rb', line 40 def finity = {}, &block @machine = Machine.new self, , &block end |
#states ⇒ Object
Return the names of all registered states.
45 46 47 |
# File 'lib/finity.rb', line 45 def states @machine.states.map { |name, _| name } end |