class FiniteMachine::GenericDSL

A generic DSL for describing the state machine

Public Class Methods

new(machine, attrs) click to toggle source

Initialize a generic DSL

@api public

# File lib/finite_machine/dsl.rb, line 13
def initialize(machine, attrs)
  @machine = machine
  @attrs   = attrs
end

Public Instance Methods

any_event() click to toggle source

Expose any event constant @api public

# File lib/finite_machine/dsl.rb, line 26
def any_event
  ANY_EVENT
end
any_state() click to toggle source

Expose any state constant @api public

# File lib/finite_machine/dsl.rb, line 20
def any_state
  ANY_STATE
end
call(&block) click to toggle source

Configure state machine properties

@api private

# File lib/finite_machine/dsl.rb, line 51
def call(&block)
  instance_eval(&block)
end
method_missing(method_name, *args, &block) click to toggle source

Delegate attributes to machine instance

@api private

Calls superclass method
# File lib/finite_machine/dsl.rb, line 33
def method_missing(method_name, *args, &block)
  if @machine.respond_to?(method_name)
    @machine.send(method_name, *args, &block)
  else
    super
  end
end
respond_to_missing?(method_name, include_private = false) click to toggle source

Check if message can be handled by this DSL

@api private

Calls superclass method
# File lib/finite_machine/dsl.rb, line 44
def respond_to_missing?(method_name, include_private = false)
  @machine.respond_to?(method_name) || super
end