Class: Poms::Api::Response
- Inherits:
-
Object
- Object
- Poms::Api::Response
- Defined in:
- lib/poms/api/response.rb
Overview
Response is an implementation-agnostic representation of an HTTP-response, composing a HTTP status code, body and hash of headers.
Instance Attribute Summary collapse
- #body ⇒ String readonly
- #code ⇒ Fixnum readonly
- #headers ⇒ Hash readonly
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
-
#initialize(code, body, headers) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(code, body, headers) ⇒ Response
Returns a new instance of Response.
15 16 17 18 19 20 |
# File 'lib/poms/api/response.rb', line 15 def initialize(code, body, headers) @code = code.to_i @body = body.to_s @headers = headers.to_h freeze end |
Instance Attribute Details
#body ⇒ String (readonly)
10 11 12 |
# File 'lib/poms/api/response.rb', line 10 def body @body end |
#code ⇒ Fixnum (readonly)
7 8 9 |
# File 'lib/poms/api/response.rb', line 7 def code @code end |
#headers ⇒ Hash (readonly)
13 14 15 |
# File 'lib/poms/api/response.rb', line 13 def headers @headers end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
22 23 24 25 26 27 |
# File 'lib/poms/api/response.rb', line 22 def eql?(other) other.is_a?(self.class) && code == other.code && body == other.body && headers == other.headers end |