Class: Contracts::ResponseAdapter
- Inherits:
-
Object
- Object
- Contracts::ResponseAdapter
- Defined in:
- lib/contracts/response_adapter.rb
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(response) ⇒ ResponseAdapter
constructor
A new instance of ResponseAdapter.
- #status ⇒ Object
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
#body ⇒ Object
11 12 13 |
# File 'lib/contracts/response_adapter.rb', line 11 def body @response.body end |
#headers ⇒ Object
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 |
#status ⇒ Object
7 8 9 |
# File 'lib/contracts/response_adapter.rb', line 7 def status @response.code end |