31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/rails/templates/indexer.rb', line 31
def perform(operation, klass, record_id, options={})
logger.debug [operation, "#{klass}##{record_id} #{options.inspect}"]
case operation.to_s
when /index|update/
record = klass.constantize.find(record_id)
record.__elasticsearch__.client = Client
record.__elasticsearch__.__send__ "#{operation}_document"
when /delete/
Client.delete index: klass.constantize.index_name, id: record_id
else raise ArgumentError, "Unknown operation '#{operation}'"
end
end
|