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.
-
#inherited(klass) ⇒ Object
When inheriting this module, pass the registered machines to the inheriting class after executing potential parent inheritance logic.
-
#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.
56 57 58 |
# File 'lib/finity.rb', line 56 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.
46 47 48 |
# File 'lib/finity.rb', line 46 def finity = {}, &block @machine = Machine.new self, , &block end |
#inherited(klass) ⇒ Object
When inheriting this module, pass the registered machines to the inheriting class after executing potential parent inheritance logic.
40 41 42 |
# File 'lib/finity.rb', line 40 def inherited klass super and klass.machine = machine end |
#states ⇒ Object
Return the names of all registered states.
51 52 53 |
# File 'lib/finity.rb', line 51 def states @machine.states.map { |name, _| name } end |