class Celluloid::AsyncProxy - celluloid-0.15.2 Documentation

# class Celluloid::AsyncProxy

A proxy which sends asynchronous calls to an actor

### Attributes

mailbox[R]

### Public Class Methods

new(mailbox, klass) click to toggle source

    # File lib/celluloid/proxies/async_proxy.rb, line 9
    def initialize(mailbox, klass)
      @mailbox, @klass = mailbox, klass
    end

### Public Instance Methods

__class__() click to toggle source

Used for reflecting on proxy objects themselves

    # File lib/celluloid/proxies/async_proxy.rb, line 7
    def __class__; AsyncProxy; end

inspect() click to toggle source

    # File lib/celluloid/proxies/async_proxy.rb, line 13
    def inspect
      "#<Celluloid::AsyncProxy(#{@klass})>"
    end

method_missing(meth, *args, &block) click to toggle source

    # File lib/celluloid/proxies/async_proxy.rb, line 17
    def method_missing(meth, *args, &block)
      if @mailbox == ::Thread.current[:celluloid_mailbox]
        args.unshift meth
        meth = :__send__
      end

      if block_given?
        # FIXME: nicer exception
        raise "Cannot use blocks with async yet"
      end

      @mailbox << AsyncCall.new(meth, args, block)
    end