Class: Namira::Request
- Inherits:
-
Object
- Object
- Namira::Request
- Defined in:
- lib/namira/request.rb
Overview
Instance Attribute Summary collapse
-
#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_request ⇒ Object
Sends the request.
Constructor Details
#initialize(uri:, http_method: :get, headers: {}, body: nil, config: {}) ⇒ Request
Create a new request
19 20 21 22 23 24 25 26 |
# File 'lib/namira/request.rb', line 19 def initialize(uri:, http_method: :get, headers: {}, body: nil, config: {}) @uri = uri @http_method = http_method @headers = Hash(headers) @body = body @config = Namira.configure.to_h.merge(Hash(config)) @stack = Namira::Stack.default end |
Instance Attribute Details
#http_method ⇒ Object (readonly)
Returns the value of attribute http_method.
9 10 11 |
# File 'lib/namira/request.rb', line 9 def http_method @http_method end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/namira/request.rb', line 9 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.
42 43 44 45 |
# File 'lib/namira/request.rb', line 42 def response send_request if @response.nil? @response end |
#send_request ⇒ Object
Sends the request.
Every time this method is called a network request will be sent.
32 33 34 |
# File 'lib/namira/request.rb', line 32 def send_request @response = _send_request end |