Module: Finity::ClassMethods

Defined in:
lib/finity.rb

Overview

Class methods to be injected into the including class upon inclusion.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#machineObject

Returns the value of attribute machine.



36
37
38
# File 'lib/finity.rb', line 36

def machine
  @machine
end

Instance Method Details

#eventsObject

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 options = {}, &block
  @machine = Machine.new self, options, &block
end

#statesObject

Return the names of all registered states.



45
46
47
# File 'lib/finity.rb', line 45

def states
  @machine.states.map { |name, _| name }
end