Class: Celluloid::Proxy::Async
- Defined in:
- lib/celluloid/proxy/async.rb
Overview
A proxy which sends asynchronous calls to an actor
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) ⇒ Async
constructor
A new instance of Async.
- #inspect ⇒ Object
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(mailbox, klass) ⇒ Async
Returns a new instance of Async.
10 11 12 13 |
# File 'lib/celluloid/proxy/async.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
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/celluloid/proxy/async.rb', line 19 def method_missing(meth, *args, &block) if @mailbox == ::Thread.current[:celluloid_mailbox] args.unshift meth meth = :__send__ end if block_given? # FIXME: nicer exception fail "Cannot use blocks with async yet" end @mailbox << ::Celluloid::Call::Async.new(meth, args, block) self end |
Instance Attribute Details
#mailbox ⇒ Object (readonly)
Returns the value of attribute mailbox.
3 4 5 |
# File 'lib/celluloid/proxy/async.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/async.rb', line 6 def __class__ ::Celluloid::Proxy::Async end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/celluloid/proxy/async.rb', line 15 def inspect "#<Celluloid::Proxy::Async(#{@klass})>" end |