Module: Elasticsearch::Model::TransactionalCallbacks::Relation

Defined in:
lib/elasticsearch/model/transactional_callbacks/relation.rb

Overview

Override .update_all and .delete_all of ActiveRecord::Relation to batch update/delete the index if the resources in question have a coresponding elasticsearch index

This module are automatically included into ActiveRecord::Relation inside of railtie

Instance Method Summary collapse

Instance Method Details

#delete_allObject



23
24
25
26
27
28
29
# File 'lib/elasticsearch/model/transactional_callbacks/relation.rb', line 23

def delete_all
  Manager.capture do
    Manager.queue.push_all(:delete, self)

    super
  end
end

#update_all(*arguments) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/elasticsearch/model/transactional_callbacks/relation.rb', line 15

def update_all(*arguments)
  Manager.capture do
    Manager.queue.push_all(:update, self)

    super(*arguments)
  end
end