Class: Sequencescape::Search::SingleResultHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Sequencescape::Search::SingleResultHandler
- Defined in:
- lib/sequencescape/search.rb
Overview
The response from the server contains the JSON for the resource found. Using this we can handle the redirection by using the appropriate model based on the root element of the JSON. We don't even need to follow the redirect!
Instance Method Summary (collapse)
-
- (SingleResultHandler) initialize(api)
constructor
A new instance of SingleResultHandler.
- - (Object) redirection(json, &block)
Methods inherited from BaseHandler
Methods included from Api::BasicErrorHandling
Constructor Details
- (SingleResultHandler) initialize(api)
A new instance of SingleResultHandler
16 17 18 |
# File 'lib/sequencescape/search.rb', line 16 def initialize(api) @api = api end |
Instance Method Details
- (Object) redirection(json, &block)
20 21 22 23 |
# File 'lib/sequencescape/search.rb', line 20 def redirection(json, &block) json.delete('uuids_to_ids') Sequencescape::Api::FinderMethods::FindByUuidHandler.new(@api.send(json.keys.first)).success(json) end |