Class: Contracts::ResponseAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/contracts/response_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ResponseAdapter

Returns a new instance of ResponseAdapter.



3
4
5
# File 'lib/contracts/response_adapter.rb', line 3

def initialize(response)
  @response = response
end

Instance Method Details

#bodyObject



11
12
13
# File 'lib/contracts/response_adapter.rb', line 11

def body
  @response.body
end

#headersObject



15
16
17
18
19
20
21
22
# File 'lib/contracts/response_adapter.rb', line 15

def headers
  # Normalize headers values according to RFC2616
  # http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
  normalized_headers = @response.headers.map do |(key, value)|
    [key, value.join(',')]
  end
  Hash[normalized_headers]
end

#statusObject



7
8
9
# File 'lib/contracts/response_adapter.rb', line 7

def status
  @response.code
end