Exception: RestfulResource::HttpClient::HttpError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/restful_resource/http_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, response = nil) ⇒ HttpError

Returns a new instance of HttpError.



9
10
11
# File 'lib/restful_resource/http_client.rb', line 9

def initialize(request, response = nil)
  @request, @response = request, assign_response(response)
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



7
8
9
# File 'lib/restful_resource/http_client.rb', line 7

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



7
8
9
# File 'lib/restful_resource/http_client.rb', line 7

def response
  @response
end

Instance Method Details

#assign_response(response = nil) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/restful_resource/http_client.rb', line 13

def assign_response(response = nil)
  if response
    @response = Response.new(body: response[:body], headers: response[:headers], status: response[:status])
  else
    @response = Response.new
  end
end