Module: Postjob::Queue::Search
- Included in:
- Postjob::Queue
- Defined in:
- lib/postjob/queue/search.rb,
lib/postjob/queue/search/scope_builder.rb
Defined Under Namespace
Classes: ScopeBuilder
Instance Method Summary collapse
-
#search(model, filter = {}) ⇒ Object
Builds a search scope (see Simple::SQL::Scope) for the passed in filter criteria.
Instance Method Details
#search(model, filter = {}) ⇒ Object
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.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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 |