53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/chewy/type/observe.rb', line 53
def update_index(objects, options = {})
if Chewy.atomic?
relation = (defined?(::ActiveRecord) && objects.is_a?(::ActiveRecord::Relation)) ||
(defined?(::Mongoid) && objects.is_a?(::Mongoid::Criteria))
ids = if relation
objects.pluck(:id)
else
Array.wrap(objects).map { |object| object.respond_to?(:id) ? object.id : object.to_i }
end
Chewy.stash self, ids
elsif options[:urgent]
ActiveSupport::Deprecation.warn("`urgent: true` option is deprecated and will be removed soon, use `Chewy.atomic` block instead")
import(objects)
elsif Chewy.urgent_update
import(objects)
end if objects
true
end
|