class FiniteMachine::AsyncCall

An immutable asynchronouse call representation that wraps the {Callable} object

Used internally by {MessageQueue} to dispatch events

@api private

Public Class Methods

new(context, callable, *args, &block) click to toggle source

Create asynchronous call instance

@param [Object] context @param [Callable] callable @param [Array] args @param [#call] block

@example

AsyncCall.new(context, Callable.new(:method), :a, :b)

@api public

# File lib/finite_machine/async_call.rb, line 22
def initialize(context, callable, *args, &block)
  @context   = context
  @callable  = callable
  @arguments = args.dup
  @block     = block
  freeze
end

Public Instance Methods

dispatch() click to toggle source

Dispatch the event to the context

@return [nil]

@api private

# File lib/finite_machine/async_call.rb, line 35
def dispatch
  @callable.call(@context, *@arguments, &@block)
end