Class: PromisePool::Future
- Inherits:
-
BasicObject
- Defined in:
- lib/promise_pool/future.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(promise) ⇒ Future
Returns a new instance of Future.
19
20
21
|
# File 'lib/promise_pool/future.rb', line 19
def initialize promise
@promise = promise
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(msg, *args, &block) ⇒ Object
23
24
25
|
# File 'lib/promise_pool/future.rb', line 23
def method_missing msg, *args, &block
@promise.yield.__send__(msg, *args, &block)
end
|
Class Method Details
.resolve(future) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/promise_pool/future.rb', line 4
def self.resolve future
if future.kind_of?(::Array)
future.map(&method(:resolve))
elsif future.kind_of?(::Hash)
future.inject({}) do |r, (k, v)|
r[k] = resolve(v)
r
end
else
future.itself
end
end
|
Instance Method Details
#respond_to_missing?(msg, *args, &block) ⇒ Boolean
27
28
29
|
# File 'lib/promise_pool/future.rb', line 27
def respond_to_missing? msg, *args, &block
@promise.yield.respond_to?(msg, *args, &block)
end
|