incrdecr_cached_counts 0.0.1 → 0.0.2
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/cached_counts/version.rb +1 -1
- data/lib/cached_counts.rb +4 -1
- 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: 4cdf727f62eeaba2d92b74a551ffc79fb43a3c9d
|
4
|
+
data.tar.gz: 12cb21eed0b602030c5a0f2979cc57c553586136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c7287f505e948a84d597411cec421e543adf04df6a7d33f698c24b6cbfaa82a53af594d8d3fb5249c35b6c3589c9ace204baa8781118423fc1c3014fa66f333
|
7
|
+
data.tar.gz: 6a40ec8e663b6a37ab74d2a7fe1c41f8b0b18e1e09edd5114f32cc9e11fd503cc37e5deb320eb2f56ed6bc1f2fe2328d3540a83fc97e13ded0197d474ef6173d
|
data/lib/cached_counts.rb
CHANGED
@@ -297,6 +297,9 @@ module CachedCounts
|
|
297
297
|
|
298
298
|
counted_class.after_commit increment_hook, options.slice(:if).merge(on: :create)
|
299
299
|
|
300
|
+
# This is ridiculous, but I can't find a better way to test for it
|
301
|
+
need_without_protection = instance_method(:assign_attributes).arity > 1
|
302
|
+
|
300
303
|
if (if_proc = options[:if])
|
301
304
|
if if_proc.is_a?(Symbol)
|
302
305
|
if_proc = ->{ send(options[:if]) }
|
@@ -321,7 +324,7 @@ module CachedCounts
|
|
321
324
|
end
|
322
325
|
|
323
326
|
old_version = dup
|
324
|
-
if
|
327
|
+
if need_without_protection
|
325
328
|
old_version.assign_attributes previous_values, without_protection: true
|
326
329
|
else
|
327
330
|
old_version.assign_attributes previous_values
|