Module: Elasticsearch::Model::Adapter::Mongoid::Callbacks

Defined in:
lib/elasticsearch/model/adapters/mongoid.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Handle index updates (creating, updating or deleting documents) when the model changes, by hooking into the lifecycle



70
71
72
73
74
# File 'lib/elasticsearch/model/adapters/mongoid.rb', line 70

def self.included(base)
  base.after_create  { |document| document.__elasticsearch__.index_document  }
  base.after_update  { |document| document.__elasticsearch__.update_document }
  base.after_destroy { |document| document.__elasticsearch__.delete_document }
end