Class: Sequencescape::Search

Inherits:
Api::Resource show all
Defined in:
lib/sequencescape/search.rb

Defined Under Namespace

Classes: BaseHandler, MultipleResultHandler, MultipleResultPaged, SingleResultHandler

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Api::Resource

#initialize, is_a_proxied_model?

Methods included from Api::Resource::Attributes

extended

Methods included from Api::Resource::Groups

#attribute_group, extended

Methods included from Api::Associations

extended

Methods included from Api::Composition

#composed_of

Methods included from Api::Actions

extended

Methods included from Api::Resource::Json

#as_json, #changed?, #coerce_to, included

Methods included from Api::ErrorHandling

included

Methods included from Api::Resource::Modifications

#initialize, #save!, #update_attributes!

Methods included from Api::Resource::InstanceMethods

#eql?, included, #initialize

Methods included from Api::Resource::ActiveModel

included, #persisted?

Constructor Details

This class inherits a constructor from Sequencescape::Api::Resource

Class Method Details

.search_action(name) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/sequencescape/search.rb', line 62

def self.search_action(name)
  line = __LINE__ + 1
  class_eval("
    def #{name}(criteria = {})
      api.create(actions.#{name}, { 'search' => criteria }, SingleResultHandler.new(api))
    end
  ", __FILE__, line)
end

Instance Method Details

#all(model, criteria = {}) ⇒ Object

When performing a search for all records we need to provide the model (as in ‘api.plate’) that we expect to be returned. So there is a limitation at the moment that the results can only belong to the same model hierarchy.



79
80
81
# File 'lib/sequencescape/search.rb', line 79

def all(model, criteria = {})
  api.create(actions.all, { 'search' => criteria }, MultipleResultHandler.new(api, model))
end