Class: Hactor::HTTP::Response

Inherits:
Delegator
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hactor/http/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, options = {}) ⇒ Response

Returns a new instance of Response.



19
20
21
22
23
24
# File 'lib/hactor/http/response.rb', line 19

def initialize(response, options={})
  @http_client = options.fetch(:http_client)
  @codec = options.fetch(:codec) { Hactor::HAL::Document }
  @body = options[:body]
  @response = response
end

Instance Attribute Details

#codecObject (readonly)

Returns the value of attribute codec.



10
11
12
# File 'lib/hactor/http/response.rb', line 10

def codec
  @codec
end

#http_clientObject

Returns the value of attribute http_client.



11
12
13
# File 'lib/hactor/http/response.rb', line 11

def http_client
  @http_client
end

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/hactor/http/response.rb', line 10

def response
  @response
end

Instance Method Details

#__getobj__Object



31
32
33
# File 'lib/hactor/http/response.rb', line 31

def __getobj__
  response
end

#bodyObject



26
27
28
29
# File 'lib/hactor/http/response.rb', line 26

def body
  @body ||= codec.new __getobj__.body,
                      response: self
end