Class: Esse::AsyncIndexing::ActiveRecordCallbacks::OnUpdate

Inherits:
Callback
  • Object
show all
Defined in:
lib/esse/async_indexing/active_record_callbacks/on_update.rb

Instance Attribute Summary

Attributes inherited from Callback

#service_name

Instance Method Summary collapse

Methods inherited from Callback

#initialize

Constructor Details

This class inherits a constructor from Esse::AsyncIndexing::ActiveRecordCallbacks::Callback

Instance Method Details

#call(model) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/esse/async_indexing/active_record_callbacks/on_update.rb', line 6

def call(model)
  doc_id = resolve_document_id(model)
  return true unless doc_id

  kwargs = {service: service_name, repo: repo, id: doc_id}
  if with == :update
    repo.async_indexing_job_for(:update).call(**options, **kwargs, operation: :update)
  else
    repo.async_indexing_job_for(:index).call(**options, **kwargs, operation: :index)
  end

  true
end