Class: Namira::Request
- Inherits:
-
Object
- Object
- Namira::Request
- Defined in:
- lib/namira/request.rb
Overview
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_method ⇒ Object
readonly
Returns the value of attribute http_method.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri:, http_method: :get, headers: {}, body: nil, config: {}) ⇒ Request
constructor
Create a new request.
-
#response ⇒ Namira::Response
The Response for the request.
- #send_async(queue_name: nil, adapter: nil) ⇒ Object
-
#send_request ⇒ Object
Sends the request.
Constructor Details
#initialize(uri:, http_method: :get, headers: {}, body: nil, config: {}) ⇒ Request
Create a new request
20 21 22 23 24 25 26 27 |
# File 'lib/namira/request.rb', line 20 def initialize(uri:, http_method: :get, headers: {}, body: nil, config: {}) @uri = uri @http_method = http_method @headers = Hash(headers) @body = body @config = Namira.config.to_h.merge(Hash(config)) @stack = Namira::Stack.default end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/namira/request.rb', line 10 def body @body end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/namira/request.rb', line 10 def config @config end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
10 11 12 |
# File 'lib/namira/request.rb', line 10 def headers @headers end |
#http_method ⇒ Object (readonly)
Returns the value of attribute http_method.
10 11 12 |
# File 'lib/namira/request.rb', line 10 def http_method @http_method end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
10 11 12 |
# File 'lib/namira/request.rb', line 10 def uri @uri end |
Instance Method Details
#response ⇒ Namira::Response
The Namira::Response for the request.
If the request hasn’t been sent yet calling this will get the request.
47 48 49 50 |
# File 'lib/namira/request.rb', line 47 def response send_request if @response.nil? @response end |
#send_async(queue_name: nil, adapter: nil) ⇒ Object
37 38 39 |
# File 'lib/namira/request.rb', line 37 def send_async(queue_name: nil, adapter: nil) Namira::Async::Performer.schedule(self, adapter, queue_name) end |
#send_request ⇒ Object
Sends the request.
Every time this method is called a network request will be sent.
33 34 35 |
# File 'lib/namira/request.rb', line 33 def send_request @response = _send_request end |