Module: Elasticsearch::Model::Extensions::PartialUpdating
- Defined in:
- lib/elasticsearch/model/extensions/partial_updating.rb,
lib/elasticsearch/model/extensions/partial_updating/partial_updater.rb
Defined Under Namespace
Modules: Callbacks, ClassMethods
Classes: PartialUpdater
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(klass) ⇒ Object
7
8
9
10
11
|
# File 'lib/elasticsearch/model/extensions/partial_updating.rb', line 7
def self.included(klass)
klass.extend ClassMethods
klass.instance_variable_set :@__partial_updater__, PartialUpdater.new(klass)
end
|
Instance Method Details
#as_indexed_json(options = {}) ⇒ Object
13
14
15
|
# File 'lib/elasticsearch/model/extensions/partial_updating.rb', line 13
def as_indexed_json(options={})
as_json(options.merge(self.class.__partial_updater__.as_json_options))
end
|
#partially_update_document(*changed_attributes) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/elasticsearch/model/extensions/partial_updating.rb', line 17
def partially_update_document(*changed_attributes)
if changed_attributes.empty?
__elasticsearch__.index_document
else
partial_updater = self.class.__partial_updater__
partial_document = partial_updater.build_partial_document_for_update_with_error_logging(
record: self,
changed_attributes: changed_attributes
)
if partial_document
partial_updater.update_document(id: self.id, doc: partial_document)
end
end
true
end
|