Class: Docomoru::Response
- Inherits:
-
Object
- Object
- Docomoru::Response
- Defined in:
- lib/docomoru/response.rb
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(faraday_response) ⇒ Response
constructor
A new instance of Response.
- #status ⇒ Object
- #status_message ⇒ Object
Constructor Details
#initialize(faraday_response) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 |
# File 'lib/docomoru/response.rb', line 6 def initialize(faraday_response) @raw_body = faraday_response.body @raw_headers = faraday_response.headers @raw_status = faraday_response.status end |
Instance Method Details
#body ⇒ Object
12 13 14 |
# File 'lib/docomoru/response.rb', line 12 def body @raw_body end |
#headers ⇒ Object
16 17 18 19 20 |
# File 'lib/docomoru/response.rb', line 16 def headers @headers ||= @raw_headers.inject({}) do |result, (key, value)| result.merge(key.split("-").map(&:capitalize).join("-") => value) end end |
#status ⇒ Object
22 23 24 |
# File 'lib/docomoru/response.rb', line 22 def status @raw_status end |
#status_message ⇒ Object
26 27 28 |
# File 'lib/docomoru/response.rb', line 26 def Rack::Utils::HTTP_STATUS_CODES[status] end |