Class: OpenLoam::Search::Driver
- Inherits:
-
Object
- Object
- OpenLoam::Search::Driver
- Defined in:
- lib/open_loam/search/driver.rb
Overview
The driver contract. Subclass and override the class methods.
search(model, query, scope:) -> a relation
Return a subset of `scope` (already tenant-scoped, and any saved-view
filter already applied) matching `query`. MUST return a relation so it
composes with the caller's own `.where`/`.order`/`.limit`. A blank
query returns `scope` unchanged (an empty search box is "no filter").
index(record) / remove(record)
Maintain the driver's index as records are saved and destroyed. Called
from OpenLoam::Searchable's after_save / after_destroy.
reindex(model)
Rebuild the index for a model (used by `open_loam:search:reindex` and seeds).
A driver that needs no index (LIKE) leaves index/remove/reindex as no-ops.
Direct Known Subclasses
Class Method Summary collapse
- .index(record) ⇒ Object
- .reindex(model) ⇒ Object
- .remove(record) ⇒ Object
- .search(model, query, scope:) ⇒ Object
Class Method Details
.index(record) ⇒ Object
25 |
# File 'lib/open_loam/search/driver.rb', line 25 def index(record) = nil |
.reindex(model) ⇒ Object
27 |
# File 'lib/open_loam/search/driver.rb', line 27 def reindex(model) = nil |
.remove(record) ⇒ Object
26 |
# File 'lib/open_loam/search/driver.rb', line 26 def remove(record) = nil |
.search(model, query, scope:) ⇒ Object
21 22 23 |
# File 'lib/open_loam/search/driver.rb', line 21 def search(model, query, scope:) raise NotImplementedError, "#{name} must implement .search(model, query, scope:)" end |