counter_culture 3.13.1 → 3.13.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/CHANGELOG.md +5 -0
- data/lib/counter_culture/counter.rb +16 -16
- data/lib/counter_culture/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8dcb5f1c57a5fda38de103fdcdf767e990f507b994c1d2e59debdbde0b1f3ef3
|
|
4
|
+
data.tar.gz: 8945d83862559fb693b79d1837507c23f978828e3d9c377f2d4cacf67d4843cc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 398000f43d6feb9165c54ec2e3614b65bb9f384e8c8f9693d6956ee9e22d2e2eec6bad28b7cdab21b1fd2543fbee05f3f04d7f697a60a740fbdd00e20e960d9b
|
|
7
|
+
data.tar.gz: 7a8e5b137d1266161ff9cb3569005f2acd147829656fc66b1aabcb0bf0d3e0a823bc3398b0b6573c6b01e394f996436a53861949e09560ca5219b414ad67193b
|
data/CHANGELOG.md
CHANGED
|
@@ -410,9 +410,7 @@ module CounterCulture
|
|
|
410
410
|
|
|
411
411
|
# update associated object counter attribute
|
|
412
412
|
def assign_to_associated_object(obj, relation, change_counter_column, operator, delta_magnitude)
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
association_object = association_object_for_assign(obj, association_name)
|
|
413
|
+
association_object = association_object_for_assign(obj, relation)
|
|
416
414
|
return if association_object.blank? || association_object.frozen?
|
|
417
415
|
|
|
418
416
|
association_object.assign_attributes(
|
|
@@ -422,21 +420,23 @@ module CounterCulture
|
|
|
422
420
|
association_object_clear_change(association_object, change_counter_column)
|
|
423
421
|
end
|
|
424
422
|
|
|
425
|
-
def association_object_for_assign(obj,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
#
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
423
|
+
def association_object_for_assign(obj, relation)
|
|
424
|
+
relation = relation.is_a?(Enumerable) ? relation.dup : [relation]
|
|
425
|
+
|
|
426
|
+
while !obj.nil? && relation.size > 0
|
|
427
|
+
cur_relation = relation.shift
|
|
428
|
+
# This isn't an association (e.g. it uses delegate), so we can't update the count this way
|
|
429
|
+
return nil if obj.class.reflect_on_association(cur_relation).nil?
|
|
430
|
+
|
|
431
|
+
if !obj.association(cur_relation).loaded?
|
|
432
|
+
# If the association isn't loaded, no need to update the count
|
|
433
|
+
return nil
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
obj = obj.public_send(cur_relation)
|
|
437
437
|
end
|
|
438
438
|
|
|
439
|
-
obj
|
|
439
|
+
obj
|
|
440
440
|
end
|
|
441
441
|
|
|
442
442
|
def association_object_clear_change(association_object, change_counter_column)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: counter_culture
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.13.
|
|
4
|
+
version: 3.13.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Magnus von Koeller
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-06-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|