Class: Celluloid::Proxy::Future
- Defined in:
- lib/celluloid/proxy/future.rb
Overview
A proxy which creates future 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) ⇒ Future
constructor
A new instance of Future.
- #inspect ⇒ Object
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(mailbox, klass) ⇒ Future
Returns a new instance of Future.
10 11 12 13 |
# File 'lib/celluloid/proxy/future.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 31 32 33 34 35 |
# File 'lib/celluloid/proxy/future.rb', line 19 def method_missing(meth, *args, &block) unless @mailbox.alive? fail ::Celluloid::DeadActorError, "attempted to call a dead actor" end if block_given? # FIXME: nicer exception fail "Cannot use blocks with futures yet" end future = ::Celluloid::Future.new call = ::Celluloid::Call::Sync.new(future, meth, args, block) @mailbox << call future end |
Instance Attribute Details
#mailbox ⇒ Object (readonly)
Returns the value of attribute mailbox.
3 4 5 |
# File 'lib/celluloid/proxy/future.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/future.rb', line 6 def __class__ ::Celluloid::Proxy::Future end |
#inspect ⇒ Object
15 16 17 |
# File 'lib/celluloid/proxy/future.rb', line 15 def inspect "#<Celluloid::Proxy::Future(#{@klass})>" end |