Class: Eezee::Response
- Inherits:
-
Object
- Object
- Eezee::Response
- Defined in:
- lib/eezee/response.rb
Instance Attribute Summary collapse
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object
-
#initialize(original) ⇒ Response
constructor
A new instance of Response.
- #log ⇒ Object
- #success? ⇒ Boolean
- #timeout? ⇒ Boolean
Constructor Details
#initialize(original) ⇒ Response
Returns a new instance of Response.
10 11 12 |
# File 'lib/eezee/response.rb', line 10 def initialize(original) @original = original end |
Instance Attribute Details
#original ⇒ Object (readonly)
Returns the value of attribute original.
8 9 10 |
# File 'lib/eezee/response.rb', line 8 def original @original end |
Instance Method Details
#body ⇒ Object
14 15 16 17 18 |
# File 'lib/eezee/response.rb', line 14 def body return {} if timeout? @body ||= parsed_body end |
#code ⇒ Object
26 27 28 29 30 |
# File 'lib/eezee/response.rb', line 26 def code return if timeout? @code ||= success_response? ? @original.status : @original.response[:status] end |
#log ⇒ Object
38 39 40 |
# File 'lib/eezee/response.rb', line 38 def log Eezee::Logger.response(self) end |
#success? ⇒ Boolean
20 21 22 23 24 |
# File 'lib/eezee/response.rb', line 20 def success? return false if timeout? @success ||= success_response? && @original&.success? end |
#timeout? ⇒ Boolean
32 33 34 35 36 |
# File 'lib/eezee/response.rb', line 32 def timeout? @original.is_a?(Faraday::TimeoutError) || @original.is_a?(Net::ReadTimeout) || @original.is_a?(Faraday::ConnectionFailed) end |