Class: Dharma::KeptPromise
- Inherits:
-
Object
- Object
- Dharma::KeptPromise
show all
- Includes:
- PromiseActions
- Defined in:
- lib/dharma/kept_promise.rb
Instance Method Summary
collapse
#complete_with, #failed, #failure, #flat_map, #map, #on_failure, #on_success, #recover, #recover_with, #success, #try_failure, #try_success
Constructor Details
#initialize(value, as) ⇒ KeptPromise
Returns a new instance of KeptPromise.
5
6
7
|
# File 'lib/dharma/kept_promise.rb', line 5
def initialize(value, as)
@value, @as = value, as
end
|
Instance Method Details
#completed? ⇒ Boolean
29
30
31
|
# File 'lib/dharma/kept_promise.rb', line 29
def completed?
true
end
|
#failure? ⇒ Boolean
9
10
11
|
# File 'lib/dharma/kept_promise.rb', line 9
def failure?
@as == :failure
end
|
#on_complete(cb = nil, &block) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/dharma/kept_promise.rb', line 33
def on_complete(cb = nil, &block)
cb ||= block
cb.call(@value, @as)
return
end
|
#ready(at_most = nil) ⇒ Object
21
22
23
|
# File 'lib/dharma/kept_promise.rb', line 21
def ready(at_most = nil)
return self
end
|
#result(at_most = nil) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/dharma/kept_promise.rb', line 13
def result(at_most = nil)
if @as == :failure
raise @value
else
return @value
end
end
|
#value ⇒ Object
25
26
27
|
# File 'lib/dharma/kept_promise.rb', line 25
def value
@value
end
|