Class: Future
Defined Under Namespace
Modules: ObjectExtension
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
-
#initialize(obj, name, args, block) ⇒ Future
constructor
A new instance of Future.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(obj, name, args, block) ⇒ Future
Returns a new instance of Future.
5 6 7 8 9 10 11 |
# File 'lib/future.rb', line 5 def initialize(obj, name, args, block) @obj, @name, @args, @block = obj, name, args, block @th = Thread.start do Thread.pass # 一応明示的に pass しておく @obj.send(@name, *@args, &@block) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
13 14 15 |
# File 'lib/future.rb', line 13 def method_missing(name, *args, &block) @th.value.send(name, *args, &block) end |