Module: Finite::ClassMethods

Defined in:
lib/finite/class_methods.rb

Overview

The class methods for any class that include the finite base

Instance Method Summary collapse

Instance Method Details

#finite(opts, &block) ⇒ Object

The finite method for the dsl

Parameters:

  • opts (Hash)

    any options including initial state

  • block (Block)

    the block of code that creates the state machine



8
9
10
11
# File 'lib/finite/class_methods.rb', line 8

def finite(opts, &block)
  StateMachine.machines ||= Hash.new
  StateMachine.machines[self] = StateMachine.new(opts[:initial], self, &block)
end