Class: ZipFinder::ResponseHandler
- Inherits:
-
Object
- Object
- ZipFinder::ResponseHandler
- Includes:
- Loggable
- Defined in:
- lib/zipfinder/response_handler.rb
Instance Attribute Summary collapse
-
#json_adapter ⇒ Object
Returns the value of attribute json_adapter.
Instance Method Summary collapse
-
#initialize(json_adapter = JSON) ⇒ ResponseHandler
constructor
A new instance of ResponseHandler.
- #process(response) ⇒ Object
Constructor Details
#initialize(json_adapter = JSON) ⇒ ResponseHandler
Returns a new instance of ResponseHandler.
6 7 8 |
# File 'lib/zipfinder/response_handler.rb', line 6 def initialize(json_adapter = JSON) @json_adapter = json_adapter end |
Instance Attribute Details
#json_adapter ⇒ Object
Returns the value of attribute json_adapter.
4 5 6 |
# File 'lib/zipfinder/response_handler.rb', line 4 def json_adapter @json_adapter end |
Instance Method Details
#process(response) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/zipfinder/response_handler.rb', line 10 def process(response) if response.status == 200 json_adapter.parse response.body else log "ZipFinder::RequestFailedError : #{response.}" raise RequestFailedError, response. end end |