Class: Poms::Api::Response

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#bodyString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/poms/api/response.rb', line 10

def body
  @body
end

#codeFixnum (readonly)

Returns:

  • (Fixnum)


7
8
9
# File 'lib/poms/api/response.rb', line 7

def code
  @code
end

#headersHash (readonly)

Returns:

  • (Hash)


13
14
15
# File 'lib/poms/api/response.rb', line 13

def headers
  @headers
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


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