Sha256: a31ec5b01a402936130913f2a022c90f9133aae0e0c1776db6ff37c4a5bea120

Contents?: true

Size: 899 Bytes

Versions: 5

Compression:

Stored size: 899 Bytes

Contents

# frozen_string_literal: true

module FiniteMachine
  # An immutable asynchronouse call representation that wraps
  # the {Callable} object
  #
  # Used internally by {MessageQueue} to dispatch events
  #
  # @api private
  class AsyncCall
    # 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
    def initialize(context, callable, *args, &block)
      @context   = context
      @callable  = callable
      @arguments = args.dup
      @block     = block
      freeze
    end

    # Dispatch the event to the context
    #
    # @return [nil]
    #
    # @api private
    def dispatch
      @callable.call(@context, *@arguments, &@block)
    end
  end # AsyncCall
end # FiniteMachine

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
finite_machine-0.14.1 lib/finite_machine/async_call.rb
finite_machine-0.14.0 lib/finite_machine/async_call.rb
finite_machine-0.13.0 lib/finite_machine/async_call.rb
finite_machine-0.12.1 lib/finite_machine/async_call.rb
finite_machine-0.12.0 lib/finite_machine/async_call.rb