Class: Searchkick::ReindexV2Job
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Searchkick::ReindexV2Job
- Defined in:
- lib/searchkick/reindex_v2_job.rb
Instance Method Summary collapse
Instance Method Details
#perform(klass, id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/searchkick/reindex_v2_job.rb', line 5 def perform(klass, id) model = klass.constantize record = model.find(id) rescue nil # TODO fix lazy coding index = model.searchkick_index if !record || !record.should_index? # hacky record ||= model.new record.id = id begin index.remove record rescue Elasticsearch::Transport::Transport::Errors::NotFound # do nothing end else index.store record end end |