Class: Routemaster::Responses::ResponsePromise
- Inherits:
-
Object
- Object
- Routemaster::Responses::ResponsePromise
- Extended by:
- Forwardable
- Defined in:
- lib/routemaster/responses/response_promise.rb
Defined Under Namespace
Modules: Pool
Instance Attribute Summary collapse
-
#body ⇒ Hashie::Mash
Delegated to the
block
's return value. -
#headers ⇒ Hash
Delegated to the
block
's return value. -
#status ⇒ Integer
Delegated to the
block
's return value.
Instance Method Summary collapse
-
#initialize(&block) ⇒ ResponsePromise
constructor
The
block
is expected to return a Response. - #method_missing(m, *args, &block) ⇒ Object
- #value ⇒ Object
Methods included from Forwardable
Constructor Details
#initialize(&block) ⇒ ResponsePromise
The block
is expected to return a Response
12 13 14 |
# File 'lib/routemaster/responses/response_promise.rb', line 12 def initialize(&block) @promise = Concurrent::Promise.execute(executor: Pool.current, &block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
32 33 34 |
# File 'lib/routemaster/responses/response_promise.rb', line 32 def method_missing(m, *args, &block) value.public_send(m, *args, &block) end |
Instance Attribute Details
#body ⇒ Hashie::Mash
Delegated to the block
's return value.
27 |
# File 'lib/routemaster/responses/response_promise.rb', line 27 delegate %i(status headers body) => :value |
#headers ⇒ Hash
Delegated to the block
's return value.
|
# File 'lib/routemaster/responses/response_promise.rb', line 20
|
#status ⇒ Integer
Delegated to the block
's return value.
|
# File 'lib/routemaster/responses/response_promise.rb', line 16
|
Instance Method Details
#value ⇒ Object
36 37 38 39 40 |
# File 'lib/routemaster/responses/response_promise.rb', line 36 def value @promise.value.tap do raise @promise.reason if @promise.rejected? end end |