Class: Celluloid::Proxy::Sync

Inherits:
AbstractCall show all
Defined in:
lib/celluloid/proxy/sync.rb

Overview

A proxy which sends synchronous calls to an actor

Direct Known Subclasses

Cell

Instance Attribute Summary

Attributes inherited from AbstractCall

#mailbox

Instance Method Summary collapse

Methods inherited from AbstractCall

#__klass__, #eql?, #hash, #initialize, #inspect

Methods inherited from Abstract

#__class__

Constructor Details

This class inherits a constructor from Celluloid::Proxy::AbstractCall

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/celluloid/proxy/sync.rb', line 7

def method_missing(meth, *args, &block)
  unless @mailbox.alive?
    fail ::Celluloid::DeadActorError, "attempted to call a dead actor: #{meth}"
  end

  if @mailbox == ::Thread.current[:celluloid_mailbox]
    args.unshift meth
    meth = :__send__
    # actor = Thread.current[:celluloid_actor]
    # actor = actor.behavior.subject.bare_object
    # return actor.__send__(*args, &block)
  end

  call = ::Celluloid::Call::Sync.new(::Celluloid.mailbox, meth, args, block)
  @mailbox << call
  call.value
end

Instance Method Details

#respond_to?(meth, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)

3
4
5
# File 'lib/celluloid/proxy/sync.rb', line 3

def respond_to?(meth, include_private = false)
  __class__.instance_methods.include?(meth) || method_missing(:respond_to?, meth, include_private)
end