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



51
52
53
54
55
# File 'lib/elasticsearch/model/adapters/mongoid.rb', line 51

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