Class: Sequencescape::Search

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

Defined Under Namespace

Classes: BaseHandler, MultipleResultHandler, SingleResultHandler

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Api::Actions

#has_create_action, #has_update_action

Methods included from Api::Composition

#composed_of

Methods included from Api::Associations

extended

Methods included from Api::Resource::Attributes

extended

Methods included from Api::Resource::Json

#as_json, #changed?, included

Methods included from Api::Resource::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?

Class Method Details

.search_action(name) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/sequencescape/search.rb', line 43

def self.search_action(name)
  line = __LINE__ + 1
  class_eval(%Q{
    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.



58
59
60
# File 'lib/sequencescape/search.rb', line 58

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