Class: Honeybadger::Backend::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/honeybadger/backend/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Response

Public: Initializes the Response instance.

response - With 1 argument Net::HTTPResponse, the code, body, and

message will be determined automatically. (optional)

code - The Integer status code. May also be :error for requests which

failed to reach the server.

body - The String body of the response. message - The String message returned by the server (or set by the

backend in the case of an :error code).

Returns nothing



22
23
24
25
26
27
28
29
30
# File 'lib/honeybadger/backend/base.rb', line 22

def initialize(*args)
  if (response = args.first).kind_of?(Net::HTTPResponse)
    @code, @body, @message = response.code.to_i, response.body.to_s, response.message
  else
    @code, @body, @message = args
  end

  @success = (200..299).cover?(@code)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/honeybadger/backend/base.rb', line 9

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



9
10
11
# File 'lib/honeybadger/backend/base.rb', line 9

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



9
10
11
# File 'lib/honeybadger/backend/base.rb', line 9

def message
  @message
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/honeybadger/backend/base.rb', line 32

def success?
  @success
end