Class: DevSuite::RequestLogger::Response
- Inherits:
-
Object
- Object
- DevSuite::RequestLogger::Response
- Includes:
- Utils::WarningHandler
- Defined in:
- lib/dev_suite/request_logger/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#content_length ⇒ Object
readonly
Returns the value of attribute content_length.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#response_time ⇒ Object
readonly
Returns the value of attribute response_time.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #header(key) ⇒ Object
-
#initialize(status:, message:, headers:, body:, response_time: nil) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Methods included from Utils::WarningHandler
Constructor Details
#initialize(status:, message:, headers:, body:, response_time: nil) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dev_suite/request_logger/response.rb', line 10 def initialize( status:, message:, headers:, body:, response_time: nil ) @status = status.to_i @message = @headers = headers @body = body @content_type = extract_content_type @content_length = extract_content_length @response_time = response_time validate_presence end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/dev_suite/request_logger/response.rb', line 8 def body @body end |
#content_length ⇒ Object (readonly)
Returns the value of attribute content_length.
8 9 10 |
# File 'lib/dev_suite/request_logger/response.rb', line 8 def content_length @content_length end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
8 9 10 |
# File 'lib/dev_suite/request_logger/response.rb', line 8 def content_type @content_type end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/dev_suite/request_logger/response.rb', line 8 def headers @headers end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/dev_suite/request_logger/response.rb', line 8 def @message end |
#response_time ⇒ Object (readonly)
Returns the value of attribute response_time.
8 9 10 |
# File 'lib/dev_suite/request_logger/response.rb', line 8 def response_time @response_time end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/dev_suite/request_logger/response.rb', line 8 def status @status end |
Instance Method Details
#header(key) ⇒ Object
32 33 34 |
# File 'lib/dev_suite/request_logger/response.rb', line 32 def header(key) headers[key.to_s.downcase] || headers[key.to_s] end |
#success? ⇒ Boolean
28 29 30 |
# File 'lib/dev_suite/request_logger/response.rb', line 28 def success? status.between?(200, 299) end |