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_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.
Constructor Details
#initialize(attributes) ⇒ Request
Returns a new instance of Request.
225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/raddocs/models.rb', line 225 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.
208 209 210 |
# File 'lib/raddocs/models.rb', line 208 def curl @curl end |
#request_body ⇒ Object (readonly)
Returns the value of attribute request_body.
208 209 210 |
# File 'lib/raddocs/models.rb', line 208 def request_body @request_body end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
208 209 210 |
# File 'lib/raddocs/models.rb', line 208 def request_method @request_method end |
#request_path ⇒ Object (readonly)
Returns the value of attribute request_path.
208 209 210 |
# File 'lib/raddocs/models.rb', line 208 def request_path @request_path end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
208 209 210 |
# File 'lib/raddocs/models.rb', line 208 def response_body @response_body end |
#response_status ⇒ Object (readonly)
Returns the value of attribute response_status.
208 209 210 |
# File 'lib/raddocs/models.rb', line 208 def response_status @response_status end |
Instance Method Details
#curl? ⇒ Boolean
Returns true if cURL command is present.
268 269 270 |
# File 'lib/raddocs/models.rb', line 268 def curl? !@curl.nil? end |
#request_body? ⇒ Boolean
Returns true if request body is present.
257 258 259 |
# File 'lib/raddocs/models.rb', line 257 def request_body? !@request_body.nil? end |
#request_content_type ⇒ String
Request headers must be set
263 264 265 |
# File 'lib/raddocs/models.rb', line 263 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
240 241 242 243 244 |
# File 'lib/raddocs/models.rb', line 240 def request_headers @request_headers.map do |header, value| "#{header}: #{value}" end.join("\n") end |
#request_query_parameters ⇒ String
Returns joined query parameters, eg: “key=valuenkey=value”.
247 248 249 |
# File 'lib/raddocs/models.rb', line 247 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.
252 253 254 |
# File 'lib/raddocs/models.rb', line 252 def request_query_parameters? !@request_query_parameters.empty? end |
#response? ⇒ Boolean
Returns true if the response is present.
273 274 275 |
# File 'lib/raddocs/models.rb', line 273 def response? !@response_status.nil? end |
#response_body? ⇒ Boolean
Returns true if response body is present.
285 286 287 |
# File 'lib/raddocs/models.rb', line 285 def response_body? !@response_body.nil? end |
#response_content_type ⇒ String
Response headers must be set
291 292 293 |
# File 'lib/raddocs/models.rb', line 291 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
278 279 280 281 282 |
# File 'lib/raddocs/models.rb', line 278 def response_headers @response_headers.map do |header, value| "#{header}: #{value}" end.join("\n") end |