Class: Esse::ActiveRecord::Callbacks::IndexingOnCreate

Inherits:
Esse::ActiveRecord::Callback show all
Defined in:
lib/esse/active_record/callbacks/indexing_on_create.rb

Instance Attribute Summary

Attributes inherited from Esse::ActiveRecord::Callback

#block_result, #options, #repo

Instance Method Summary collapse

Methods inherited from Esse::ActiveRecord::Callback

#initialize

Constructor Details

This class inherits a constructor from Esse::ActiveRecord::Callback

Instance Method Details

#call(model) ⇒ Object



6
7
8
9
10
11
# File 'lib/esse/active_record/callbacks/indexing_on_create.rb', line 6

def call(model)
  record = block_result || model
  document = repo.serialize(record)
  repo.index.index(document, **options) if document && !document.ignore_on_index?
  true
end