Class: GetResponse::Response
- Inherits:
-
Object
- Object
- GetResponse::Response
- Defined in:
- lib/get_response/response.rb
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
3 4 5 |
# File 'lib/get_response/response.rb', line 3 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
7 8 9 10 11 |
# File 'lib/get_response/response.rb', line 7 def body JSON.parse(@response.body) rescue JSON::ParserError => e {} end |
#success? ⇒ Boolean
13 14 15 |
# File 'lib/get_response/response.rb', line 13 def success? [200, 201, 202].include? @response.status end |