Class: Requests::PreparedRequest
- Inherits:
-
Object
- Object
- Requests::PreparedRequest
- Defined in:
- lib/requests/models.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(method:, url:, headers: nil, body: nil) ⇒ PreparedRequest
constructor
A new instance of PreparedRequest.
- #to_h ⇒ Object
Constructor Details
#initialize(method:, url:, headers: nil, body: nil) ⇒ PreparedRequest
Returns a new instance of PreparedRequest.
8 9 10 11 12 13 |
# File 'lib/requests/models.rb', line 8 def initialize(method:, url:, headers: nil, body: nil) @method = method @url = url @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/requests/models.rb', line 7 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/requests/models.rb', line 7 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/requests/models.rb', line 7 def method @method end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/requests/models.rb', line 7 def url @url end |
Instance Method Details
#[](key) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/requests/models.rb', line 14 def [](key) case key.to_sym when :method then @method when :url then @url when :headers then @headers when :body then @body end end |
#to_h ⇒ Object
22 23 24 |
# File 'lib/requests/models.rb', line 22 def to_h { method: @method, url: @url, headers: @headers, body: @body } end |