Class: Telebugs::Promise

Inherits:
Object
  • Object
show all
Defined in:
lib/telebugs/promise.rb

Overview

Wraps Concurrent::Promise to provide a consistent API for promises that we can control.

Instance Method Summary collapse

Constructor Details

#initializePromise

Returns a new instance of Promise.



7
8
9
# File 'lib/telebugs/promise.rb', line 7

def initialize(...)
  @future = Concurrent::Promises.future(...)
end

Instance Method Details

#fulfilled?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/telebugs/promise.rb', line 23

def fulfilled?
  @future.fulfilled?
end

#reasonObject



15
16
17
# File 'lib/telebugs/promise.rb', line 15

def reason
  @future.reason
end

#rejected?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/telebugs/promise.rb', line 27

def rejected?
  @future.rejected?
end

#rescueObject



35
36
37
# File 'lib/telebugs/promise.rb', line 35

def rescue(...)
  @future.rescue(...)
end

#thenObject



31
32
33
# File 'lib/telebugs/promise.rb', line 31

def then(...)
  @future.then(...)
end

#valueObject



11
12
13
# File 'lib/telebugs/promise.rb', line 11

def value
  @future.value
end

#waitObject



19
20
21
# File 'lib/telebugs/promise.rb', line 19

def wait
  @future.wait
end