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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2858d3a360d204db3c1755fecc65a5e86b3fb8e
4
- data.tar.gz: 54d6490ddd105d5ff50eebae905eb91ace85c4e8
3
+ metadata.gz: 0f35788e06224506f63bd06b886c18a47fc6d0ab
4
+ data.tar.gz: a4dc68b54d13000f4f9413bfaff2aafd1781d933
5
5
  SHA512:
6
- metadata.gz: 6db43766e1c9dd8e2a56ecd81386bc01a46b6c300fc91d823063fe5418df2e0d74910edc4053eb7e20216ea6316383e03d57ed35bbe0e6f9bffeee3d247bbbcf
7
- data.tar.gz: 64a89f3516777115416ce38f48d92317f30390c3acfbb8f770d41bbf12e6cdafd07877fc75e9d65391865099f1308fad5f2fc17792e8c6119ec8967394714aff
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
- raise MultipleWatchesProhibited.new("Cannot register an index watch on the same type more than once: #{type_name}") if model._tantot_chewy_callbacks.key?(type_name)
43
- model._tantot_chewy_callbacks[type_name] = [method, options, block]
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, (method, options, block)|
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}" }
@@ -1,3 +1,3 @@
1
1
  module Tantot
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -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 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tantot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - François-Pierre Bouchard