Class: Eezee::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/eezee/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#originalObject (readonly)

Returns the value of attribute original.



8
9
10
# File 'lib/eezee/response.rb', line 8

def original
  @original
end

Instance Method Details

#bodyObject



14
15
16
17
18
# File 'lib/eezee/response.rb', line 14

def body
  return {} if timeout?

  @body ||= parsed_body
end

#codeObject



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

#logObject



38
39
40
# File 'lib/eezee/response.rb', line 38

def log
  Eezee::Logger.response(self)
end

#success?Boolean

Returns:

  • (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

Returns:

  • (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