12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/searchkick/reindex_v2_job.rb', line 12
def perform(klass, id, method_name = nil, routing: nil)
model = klass.constantize
record =
begin
if model.respond_to?(:unscoped)
model.unscoped.find(id)
else
model.find(id)
end
rescue => e
raise e unless RECORD_NOT_FOUND_CLASSES.include?(e.class.name)
nil
end
unless record
record = model.new
record.id = id
if routing
record.define_singleton_method(:search_routing) do
routing
end
end
end
RecordIndexer.new(record).reindex(method_name, mode: :inline)
end
|