Class: Raddocs::Request
- Inherits:
-
Object
- Object
- Raddocs::Request
- Defined in:
- lib/raddocs/models.rb
Overview
Documented response
Instance Attribute Summary collapse
-
#curl ⇒ Object
readonly
Returns the value of attribute curl.
-
#request_body ⇒ Object
readonly
Returns the value of attribute request_body.
-
#request_method ⇒ Object
readonly
Returns the value of attribute request_method.
-
#request_path ⇒ Object
readonly
Returns the value of attribute request_path.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
-
#response_status ⇒ Object
readonly
Returns the value of attribute response_status.
Instance Method Summary collapse
-
#curl? ⇒ Boolean
True if cURL command is present.
-
#initialize(attributes) ⇒ Request
constructor
A new instance of Request.
-
#request_body? ⇒ Boolean
True if request body is present.
-
#request_content_type ⇒ String
Request headers must be set.
-
#request_headers ⇒ Object
There are unwanted indents if this was a simple each and output in haml.
-
#request_headers? ⇒ Boolean
True if request headers are present.
-
#request_query_parameters ⇒ String
Joined query parameters, eg: “key=valuenkey=value”.
-
#request_query_parameters? ⇒ Boolean
True if request query parameters are present.
-
#response? ⇒ Boolean
True if the response is present.
-
#response_body? ⇒ Boolean
True if response body is present.
-
#response_content_type ⇒ String
Response headers must be set.
-
#response_headers ⇒ Object
There are unwanted indents if this was a simple each and output in haml.
-
#response_headers? ⇒ Boolean
True if response headers are present.
Constructor Details
#initialize(attributes) ⇒ Request
Returns a new instance of Request.
249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/raddocs/models.rb', line 249 def initialize(attributes) @attrs = attributes @request_headers = attributes.fetch("request_headers") @request_method = attributes.fetch("request_method") @request_path = attributes.fetch("request_path") @request_query_parameters = attributes.fetch("request_query_parameters", nil) @request_body = attributes.fetch("request_body", nil) @curl = attributes.fetch("curl", nil) @response_status = attributes.fetch("response_status") @response_headers = attributes.fetch("response_headers", {}) @response_body = attributes.fetch("response_body", nil) end |
Instance Attribute Details
#curl ⇒ Object (readonly)
Returns the value of attribute curl.
232 233 234 |
# File 'lib/raddocs/models.rb', line 232 def curl @curl end |
#request_body ⇒ Object (readonly)
Returns the value of attribute request_body.
232 233 234 |
# File 'lib/raddocs/models.rb', line 232 def request_body @request_body end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
232 233 234 |
# File 'lib/raddocs/models.rb', line 232 def request_method @request_method end |
#request_path ⇒ Object (readonly)
Returns the value of attribute request_path.
232 233 234 |
# File 'lib/raddocs/models.rb', line 232 def request_path @request_path end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
232 233 234 |
# File 'lib/raddocs/models.rb', line 232 def response_body @response_body end |
#response_status ⇒ Object (readonly)
Returns the value of attribute response_status.
232 233 234 |
# File 'lib/raddocs/models.rb', line 232 def response_status @response_status end |
Instance Method Details
#curl? ⇒ Boolean
Returns true if cURL command is present.
297 298 299 |
# File 'lib/raddocs/models.rb', line 297 def curl? !@curl.nil? end |
#request_body? ⇒ Boolean
Returns true if request body is present.
281 282 283 |
# File 'lib/raddocs/models.rb', line 281 def request_body? !@request_body.nil? end |
#request_content_type ⇒ String
Request headers must be set
292 293 294 |
# File 'lib/raddocs/models.rb', line 292 def request_content_type @request_headers["Content-Type"] end |
#request_headers ⇒ Object
There are unwanted indents if this was a simple each and output in haml
264 265 266 267 268 |
# File 'lib/raddocs/models.rb', line 264 def request_headers @request_headers.map do |header, value| "#{header}: #{value}" end.join("\n") end |
#request_headers? ⇒ Boolean
Returns true if request headers are present.
286 287 288 |
# File 'lib/raddocs/models.rb', line 286 def request_headers? request_headers.length > 0 end |
#request_query_parameters ⇒ String
Returns joined query parameters, eg: “key=valuenkey=value”.
271 272 273 |
# File 'lib/raddocs/models.rb', line 271 def request_query_parameters @request_query_parameters.map { |k,v| "#{k}=#{v}" }.join("\n") end |
#request_query_parameters? ⇒ Boolean
Returns true if request query parameters are present.
276 277 278 |
# File 'lib/raddocs/models.rb', line 276 def request_query_parameters? !@request_query_parameters.empty? end |
#response? ⇒ Boolean
Returns true if the response is present.
302 303 304 |
# File 'lib/raddocs/models.rb', line 302 def response? !@response_status.nil? end |
#response_body? ⇒ Boolean
Returns true if response body is present.
314 315 316 |
# File 'lib/raddocs/models.rb', line 314 def response_body? !@response_body.nil? end |
#response_content_type ⇒ String
Response headers must be set
325 326 327 |
# File 'lib/raddocs/models.rb', line 325 def response_content_type @response_headers["Content-Type"] end |
#response_headers ⇒ Object
There are unwanted indents if this was a simple each and output in haml
307 308 309 310 311 |
# File 'lib/raddocs/models.rb', line 307 def response_headers @response_headers.map do |header, value| "#{header}: #{value}" end.join("\n") end |
#response_headers? ⇒ Boolean
Returns true if response headers are present.
319 320 321 |
# File 'lib/raddocs/models.rb', line 319 def response_headers? response_headers.length > 0 end |