Class: When::Deferred
- Inherits:
-
Object
- Object
- When::Deferred
- Defined in:
- lib/when.rb
Instance Attribute Summary collapse
-
#promise ⇒ Object
readonly
Returns the value of attribute promise.
-
#resolver ⇒ Object
readonly
Returns the value of attribute resolver.
Instance Method Summary collapse
- #callback(&block) ⇒ Object
- #errback(&block) ⇒ Object
-
#initialize ⇒ Deferred
constructor
A new instance of Deferred.
- #reject(*args) ⇒ Object
- #resolve(*args) ⇒ Object
- #resolved? ⇒ Boolean
- #then(&block) ⇒ Object
Constructor Details
Instance Attribute Details
#promise ⇒ Object (readonly)
Returns the value of attribute promise.
42 43 44 |
# File 'lib/when.rb', line 42 def promise @promise end |
#resolver ⇒ Object (readonly)
Returns the value of attribute resolver.
42 43 44 |
# File 'lib/when.rb', line 42 def resolver @resolver end |
Instance Method Details
#callback(&block) ⇒ Object
53 |
# File 'lib/when.rb', line 53 def callback(&block); add_callback(:resolved, block); end |
#errback(&block) ⇒ Object
55 |
# File 'lib/when.rb', line 55 def errback(&block); add_callback(:rejected, block); end |
#reject(*args) ⇒ Object
52 |
# File 'lib/when.rb', line 52 def reject(*args); mark_resolved(:rejected, args); end |
#resolve(*args) ⇒ Object
51 |
# File 'lib/when.rb', line 51 def resolve(*args); mark_resolved(:resolved, args); end |
#resolved? ⇒ Boolean
56 |
# File 'lib/when.rb', line 56 def resolved?; !@resolution.nil?; end |
#then(&block) ⇒ Object
54 |
# File 'lib/when.rb', line 54 def then(&block); add_callback(:resolved, block); end |