Class: Future
- Inherits:
-
PromiseApi
- Object
- PromiseApi
- Future
- Defined in:
- lib/bellite.rb
Overview
Implements Future
Instance Attribute Summary collapse
-
#promise ⇒ Promise
readonly
Promise object of this Future.
-
#reject ⇒ Proc, lambda
readonly
Failure-function.
-
#resolve ⇒ Proc, lambda
readonly
Success-function.
Instance Method Summary collapse
-
#initialize(_then, resolve = false, reject = false) ⇒ Future
constructor
Constructing object with then, success and failure functions.
- #then_(success = false, failure = false) ⇒ Object
Methods inherited from PromiseApi
Constructor Details
#initialize(_then, resolve = false, reject = false) ⇒ Future
Constructing object with then, success and failure functions
620 621 622 623 624 625 626 627 628 |
# File 'lib/bellite.rb', line 620 def initialize(_then, resolve=false, reject=false) @promise = Promise.new _then if resolve @resolve = resolve end if reject @reject = reject end end |
Instance Attribute Details
#promise ⇒ Promise (readonly)
Promise object of this Future
648 649 650 |
# File 'lib/bellite.rb', line 648 def promise @promise end |
#reject ⇒ Proc, lambda (readonly)
Failure-function
641 642 643 |
# File 'lib/bellite.rb', line 641 def reject(err) @reject.call(err) end |
#resolve ⇒ Proc, lambda (readonly)
Success-function
634 635 636 |
# File 'lib/bellite.rb', line 634 def resolve(res=true) @resolve.call(res) end |
Instance Method Details
#then_(success = false, failure = false) ⇒ Object
652 653 654 |
# File 'lib/bellite.rb', line 652 def then_(success=false, failure=false) return @promise.then_(success, failure) end |