Class: EndpointFlux::Response
- Inherits:
-
Object
- Object
- EndpointFlux::Response
- Defined in:
- lib/endpoint_flux/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
Instance Method Summary collapse
- #forbidden? ⇒ Boolean
-
#initialize(headers: {}, body: {}) ⇒ Response
constructor
A new instance of Response.
- #invalid? ⇒ Boolean
- #not_found? ⇒ Boolean
- #success? ⇒ Boolean
- #unauthorized? ⇒ Boolean
Constructor Details
#initialize(headers: {}, body: {}) ⇒ Response
Returns a new instance of Response.
3 4 5 6 |
# File 'lib/endpoint_flux/response.rb', line 3 def initialize(headers: {}, body: {}) @body = body @headers = headers end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
8 9 10 |
# File 'lib/endpoint_flux/response.rb', line 8 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
8 9 10 |
# File 'lib/endpoint_flux/response.rb', line 8 def headers @headers end |
Instance Method Details
#forbidden? ⇒ Boolean
18 19 20 |
# File 'lib/endpoint_flux/response.rb', line 18 def forbidden? body[:status] == 403 end |
#invalid? ⇒ Boolean
14 15 16 |
# File 'lib/endpoint_flux/response.rb', line 14 def invalid? body[:status] == 422 end |
#not_found? ⇒ Boolean
26 27 28 |
# File 'lib/endpoint_flux/response.rb', line 26 def not_found? body[:status] == 404 end |
#success? ⇒ Boolean
10 11 12 |
# File 'lib/endpoint_flux/response.rb', line 10 def success? body[:status] && body[:status].between?(200, 209) end |
#unauthorized? ⇒ Boolean
22 23 24 |
# File 'lib/endpoint_flux/response.rb', line 22 def body[:status] == 401 end |