module ElasticRecord::Callbacks
Public Class Methods
included(base)
click to toggle source
# File lib/elastic_record/callbacks.rb, line 3 def self.included(base) return unless base.respond_to?(:after_save) && base.respond_to?(:after_destroy) base.class_eval do after_create :index_to_elasticsearch after_update :update_index_document, if: -> { respond_to?(:saved_changes?) ? saved_changes? : changed? } after_destroy :delete_index_document end end
Private Instance Methods
delete_index_document()
click to toggle source
# File lib/elastic_record/callbacks.rb, line 21 def delete_index_document self.class.elastic_index.delete_document id end
update_index_document()
click to toggle source
# File lib/elastic_record/callbacks.rb, line 15 def update_index_document method = self.class.elastic_index.partial_updates ? :update_record : :index_record self.class.elastic_index.send(method, self) end