Class: IndexedSearch::ApplicationIndexer

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
app/indexers/indexed_search/application_indexer.rb

Overview

Base class for model search re-indexers, using observers. Inherit from this in your observers to get basic default functionality. Override these methods to alter or fine tune that functionality.

Direct Known Subclasses

ApplicationIndexer

Instance Method Summary collapse

Instance Method Details

#after_create(mdl) ⇒ Object

When a model record is created, create an index for it too, unless indexing has been temporarily disabled.



12
13
14
# File 'app/indexers/indexed_search/application_indexer.rb', line 12

def after_create(mdl)
  mdl.create_search_index unless mdl.no_indexing?
end

#after_destroy(mdl) ⇒ Object

When a model record is destroyed, get rid of its index too, unless indexing has been temporarily disabled.



22
23
24
# File 'app/indexers/indexed_search/application_indexer.rb', line 22

def after_destroy(mdl)
  mdl.delete_search_index unless mdl.no_indexing?
end

#after_update(mdl) ⇒ Object

When a model record is modified, update its index too, unless indexing has been temporarily disabled.



17
18
19
# File 'app/indexers/indexed_search/application_indexer.rb', line 17

def after_update(mdl)
  mdl.update_search_index unless mdl.no_indexing?
end