Class: Mon::Monad::FutureComplete
- Defined in:
- lib/monads/future.rb
Overview
FutureComplete represents a finalized value.
Class Method Summary collapse
-
.[](value) ⇒ Object
You should probably be using Future instead.
Instance Method Summary collapse
-
#bind(&fun) ⇒ Object
Asyrchronously apply fun to the value wrapped by this FutureComplete.
-
#initialize(value) ⇒ FutureComplete
constructor
A new instance of FutureComplete.
- #pending? ⇒ Boolean
- #to_s ⇒ Object
- #unwrap ⇒ Object
Methods inherited from Future
#==, #eql?, #equals?, eventually, valid?
Methods included from ChainableMonad
#_, #coerce, #method_missing, #respond_to?
Constructor Details
#initialize(value) ⇒ FutureComplete
Returns a new instance of FutureComplete.
121 122 123 |
# File 'lib/monads/future.rb', line 121 def initialize(value) @value = value end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Mon::Monad::ChainableMonad
Class Method Details
.[](value) ⇒ Object
You should probably be using Future instead.
126 127 128 |
# File 'lib/monads/future.rb', line 126 def self::[](value) self::new(value) end |
Instance Method Details
#bind(&fun) ⇒ Object
Asyrchronously apply fun to the value wrapped by this FutureComplete. Returns a FuturePromise.
131 132 133 |
# File 'lib/monads/future.rb', line 131 def bind &fun FuturePromise::perform(fun, [@value]) end |
#pending? ⇒ Boolean
135 136 137 |
# File 'lib/monads/future.rb', line 135 def pending? false end |
#to_s ⇒ Object
143 144 145 |
# File 'lib/monads/future.rb', line 143 def to_s "FutureComplete[#{ @value }]" end |
#unwrap ⇒ Object
139 140 141 |
# File 'lib/monads/future.rb', line 139 def unwrap @value end |