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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c327147e72e3805c900b40be70e55e8fc923a00
4
- data.tar.gz: d024e41326daa4a2cb92cfa670791bba73f5dd96
3
+ metadata.gz: 4cdf727f62eeaba2d92b74a551ffc79fb43a3c9d
4
+ data.tar.gz: 12cb21eed0b602030c5a0f2979cc57c553586136
5
5
  SHA512:
6
- metadata.gz: 0efe60b65ccd5bfcb6b4c4c083daae3218507ad7430603c587078ab5577de30a1c47427765267e8d73e65831c5515fb9c0e0b22e53e74a2cb3bc38d8f578c9e2
7
- data.tar.gz: 0945dff72c8025ad3ace58c826c1973d0d9b00dc41f4fd8d62f28e25a12b4172fc546c3e4d34d4b2d79033308febe48a033da5e696ee03768fbadb0e87ce8737
6
+ metadata.gz: 9c7287f505e948a84d597411cec421e543adf04df6a7d33f698c24b6cbfaa82a53af594d8d3fb5249c35b6c3589c9ace204baa8781118423fc1c3014fa66f333
7
+ data.tar.gz: 6a40ec8e663b6a37ab74d2a7fe1c41f8b0b18e1e09edd5114f32cc9e11fd503cc37e5deb320eb2f56ed6bc1f2fe2328d3540a83fc97e13ded0197d474ef6173d
@@ -1,3 +1,3 @@
1
1
  module CachedCounts
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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 previous_values.respond_to?(:permitted?)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: incrdecr_cached_counts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Judd