Module: SimplyFSM::ClassMethods

Defined in:
lib/simply_fsm/simply_fsm.rb

Overview

Defines the constructor for defining a state machine

Instance Method Summary collapse

Instance Method Details

#state_machine(name, opts = {}, &block) ⇒ Object

Declare a state machine called name which can then be defined by a DSL defined by the methods of StateMachine.

Parameters:

  • name (String)

    of the state machine.

  • opts (Hash) (defaults to: {})

    to specify options such as:

    • fail lambda that is called with the event name when any event fails to transition



24
25
26
27
# File 'lib/simply_fsm/simply_fsm.rb', line 24

def state_machine(name, opts = {}, &block)
  fsm = StateMachine.new(name, self, fail: opts[:fail])
  fsm.instance_eval(&block)
end