tantot 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tantot/extensions/chewy.rb +4 -6
- data/lib/tantot/version.rb +1 -1
- data/spec/extensions/chewy_spec.rb +0 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f35788e06224506f63bd06b886c18a47fc6d0ab
|
4
|
+
data.tar.gz: a4dc68b54d13000f4f9413bfaff2aafd1781d933
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31e28fe000fbe702ae6cdc8f2aa932ffe21615259b06cdaf89bec7d3ddebcd1ec6b3b55c8e712cd7ec218e33292a0c865c4456df1c84d51e720943126fc64853
|
7
|
+
data.tar.gz: 91b0f7e7bf994f95b627cfc2474cbdab5876dd0f3e3c27ed3a4632a333e8a7e639f4083360247b6c74f0a36fcceadb2b6eed4992eeb7f3b165049e94c3a5ca99
|
@@ -39,8 +39,8 @@ module Tantot
|
|
39
39
|
def self.register_watch(model, type_name, options, block)
|
40
40
|
method = options.delete(:method)
|
41
41
|
model._tantot_chewy_callbacks ||= {}
|
42
|
-
|
43
|
-
model._tantot_chewy_callbacks[type_name]
|
42
|
+
model._tantot_chewy_callbacks[type_name] ||= []
|
43
|
+
model._tantot_chewy_callbacks[type_name] << [method, options, block]
|
44
44
|
end
|
45
45
|
|
46
46
|
class ChewyWatcher
|
@@ -51,14 +51,12 @@ module Tantot
|
|
51
51
|
def perform(changes_by_model)
|
52
52
|
changes_by_model.each do |model, changes_by_id|
|
53
53
|
model_watches = model._tantot_chewy_callbacks
|
54
|
-
model_watches.each do |type_name,
|
54
|
+
model_watches.each do |type_name, watches|
|
55
55
|
# Find type
|
56
56
|
reference = get_chewy_type(type_name)
|
57
|
-
backreference = get_ids_to_update(model, changes_by_id, method, options, block)
|
58
57
|
|
58
|
+
backreference = watches.flat_map {|method, options, block| get_ids_to_update(model, changes_by_id, method, options, block)}.compact
|
59
59
|
if backreference
|
60
|
-
backreference.compact!
|
61
|
-
|
62
60
|
# Make sure there are any backreferences
|
63
61
|
if backreference.any?
|
64
62
|
Tantot.logger.debug { "[Tantot] [Chewy] [update_index] #{reference} (#{backreference.count} objects): #{backreference.inspect}" }
|
data/lib/tantot/version.rb
CHANGED
@@ -4,15 +4,6 @@ if defined?(::Chewy)
|
|
4
4
|
|
5
5
|
describe Tantot::Extensions::Chewy do
|
6
6
|
|
7
|
-
context "validations" do
|
8
|
-
it "should prevent registering on the same type more than once" do
|
9
|
-
stub_model(:city) do
|
10
|
-
watch_index 'foo'
|
11
|
-
end
|
12
|
-
expect { City.watch_index 'foo' }.to raise_error(Tantot::MultipleWatchesProhibited, /same type more than once/)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
7
|
[nil, :self, :class_method, :block].product([:some, :all]).each do |backreference_opt, attribute_opt|
|
17
8
|
context "should update indexes using backreference: #{backreference_opt.inspect}, attributes: #{attribute_opt}" do
|
18
9
|
let(:chewy_type) { double }
|