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.
240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/raddocs/models.rb', line 240 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.
223 224 225 |
# File 'lib/raddocs/models.rb', line 223 def curl @curl end |
#request_body ⇒ Object (readonly)
Returns the value of attribute request_body.
223 224 225 |
# File 'lib/raddocs/models.rb', line 223 def request_body @request_body end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
223 224 225 |
# File 'lib/raddocs/models.rb', line 223 def request_method @request_method end |
#request_path ⇒ Object (readonly)
Returns the value of attribute request_path.
223 224 225 |
# File 'lib/raddocs/models.rb', line 223 def request_path @request_path end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
223 224 225 |
# File 'lib/raddocs/models.rb', line 223 def response_body @response_body end |
#response_status ⇒ Object (readonly)
Returns the value of attribute response_status.
223 224 225 |
# File 'lib/raddocs/models.rb', line 223 def response_status @response_status end |
Instance Method Details
#curl? ⇒ Boolean
Returns true if cURL command is present.
288 289 290 |
# File 'lib/raddocs/models.rb', line 288 def curl? !@curl.nil? end |
#request_body? ⇒ Boolean
Returns true if request body is present.
272 273 274 |
# File 'lib/raddocs/models.rb', line 272 def request_body? !@request_body.nil? end |
#request_content_type ⇒ String
Request headers must be set
283 284 285 |
# File 'lib/raddocs/models.rb', line 283 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
255 256 257 258 259 |
# File 'lib/raddocs/models.rb', line 255 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.
277 278 279 |
# File 'lib/raddocs/models.rb', line 277 def request_headers? request_headers.length > 0 end |
#request_query_parameters ⇒ String
Returns joined query parameters, eg: “key=valuenkey=value”.
262 263 264 |
# File 'lib/raddocs/models.rb', line 262 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.
267 268 269 |
# File 'lib/raddocs/models.rb', line 267 def request_query_parameters? !@request_query_parameters.empty? end |
#response? ⇒ Boolean
Returns true if the response is present.
293 294 295 |
# File 'lib/raddocs/models.rb', line 293 def response? !@response_status.nil? end |
#response_body? ⇒ Boolean
Returns true if response body is present.
305 306 307 |
# File 'lib/raddocs/models.rb', line 305 def response_body? !@response_body.nil? end |
#response_content_type ⇒ String
Response headers must be set
316 317 318 |
# File 'lib/raddocs/models.rb', line 316 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
298 299 300 301 302 |
# File 'lib/raddocs/models.rb', line 298 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.
310 311 312 |
# File 'lib/raddocs/models.rb', line 310 def response_headers? response_headers.length > 0 end |