perform

in elasticsearch-rails/lib/rails/templates/indexer.rb [30:43]


  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