Class: Kongrations::Response
- Inherits:
-
Object
- Object
- Kongrations::Response
- Defined in:
- lib/kongrations/response.rb
Direct Known Subclasses
Instance Method Summary collapse
- #body ⇒ Object
- #data_to_save ⇒ Object
- #error? ⇒ Boolean
-
#initialize(response, request) ⇒ Response
constructor
A new instance of Response.
- #save_data(migration_name) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response, request) ⇒ Response
Returns a new instance of Response.
8 9 10 11 |
# File 'lib/kongrations/response.rb', line 8 def initialize(response, request) @response = response @request = request end |
Instance Method Details
#body ⇒ Object
21 22 23 |
# File 'lib/kongrations/response.rb', line 21 def body JSON.parse(@response.body, symbolize_names: true) unless @response.body.nil? end |
#data_to_save ⇒ Object
25 26 27 |
# File 'lib/kongrations/response.rb', line 25 def data_to_save nil end |
#error? ⇒ Boolean
17 18 19 |
# File 'lib/kongrations/response.rb', line 17 def error? !success? end |
#save_data(migration_name) ⇒ Object
29 30 31 |
# File 'lib/kongrations/response.rb', line 29 def save_data(migration_name) MigrationData.save(migration_name, data_to_save) end |
#success? ⇒ Boolean
13 14 15 |
# File 'lib/kongrations/response.rb', line 13 def success? @response.is_a?(Net::HTTPSuccess) end |