module Postjob::Queue::Search
Public Instance Methods
search(model, filter = {})
click to toggle source
Builds a search scope (see Simple::SQL::Scope) for the passed in filter criteria.
Parameters:
-
model: the name of the postjob model, e.g. “postjobs”, “events”, ..
-
filter: a Hash of filter values and other options. options are denoted
by a Symbol key.
Note that the search scope is unsorted.
# File lib/postjob/queue/search.rb, line 14 def search(model, filter = {}) expect! model => String expect! filter => [Hash, nil] filter = filter ? filter.dup : {} root_only = filter.delete(:root_only) attributes = filter.delete(:attributes) scope = ScopeBuilder.build(model: model, filter: filter, attributes: attributes) scope = scope.where("root_id=id") if root_only && model == "postjobs" scope end