Class: Sequencescape::Search::SingleResultHandler

Inherits:
BaseHandler
  • Object
show all
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

Methods inherited from BaseHandler

#success

Methods included from Api::BasicErrorHandling

#missing, #unauthenticated

Constructor Details

#initialize(api) ⇒ SingleResultHandler

Returns a new instance of SingleResultHandler.



16
17
18
# File 'lib/sequencescape/search.rb', line 16

def initialize(api)
  @api = api
end

Instance Method Details

#redirection(json) ⇒ Object



20
21
22
23
# File 'lib/sequencescape/search.rb', line 20

def redirection(json)
  json.delete('uuids_to_ids')
  Sequencescape::Api::FinderMethods::FindByUuidHandler.new(@api.send(json.keys.first)).success(json)
end