Class: Celluloid::Proxy::Sync
- Defined in:
- lib/celluloid/proxy/sync.rb
Overview
A proxy which sends synchronous calls to an actor
Direct Known Subclasses
Instance Attribute Summary collapse
-
#mailbox ⇒ Object
readonly
Returns the value of attribute mailbox.
Instance Method Summary collapse
-
#__class__ ⇒ Object
Used for reflecting on proxy objects themselves.
-
#initialize(mailbox, klass) ⇒ Sync
constructor
A new instance of Sync.
- #inspect ⇒ Object
- #method_missing(meth, *args, &block) ⇒ Object
- #respond_to?(meth, include_private = false) ⇒ Boolean
Constructor Details
#initialize(mailbox, klass) ⇒ Sync
Returns a new instance of Sync.
10 11 12 13 |
# File 'lib/celluloid/proxy/sync.rb', line 10 def initialize(mailbox, klass) @mailbox = mailbox @klass = klass end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/celluloid/proxy/sync.rb', line 23 def method_missing(meth, *args, &block) unless @mailbox.alive? fail ::Celluloid::DeadActorError, "attempted to call a dead actor" 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 Attribute Details
#mailbox ⇒ Object (readonly)
Returns the value of attribute mailbox.
3 4 5 |
# File 'lib/celluloid/proxy/sync.rb', line 3 def mailbox @mailbox end |
Instance Method Details
#__class__ ⇒ Object
Used for reflecting on proxy objects themselves
6 7 8 |
# File 'lib/celluloid/proxy/sync.rb', line 6 def __class__ ::Celluloid::Proxy::Sync end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/celluloid/proxy/sync.rb', line 15 def inspect "#<Celluloid::Proxy::Sync(#{@klass})>" end |
#respond_to?(meth, include_private = false) ⇒ Boolean
19 20 21 |
# File 'lib/celluloid/proxy/sync.rb', line 19 def respond_to?(meth, include_private = false) __class__.instance_methods.include?(meth) || method_missing(:respond_to?, meth, include_private) end |