counter_culture 3.10.0 → 3.10.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 +10 -0
- data/lib/counter_culture/counter.rb +26 -8
- 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: dc2af460731ae5d0d71c452bff1969ede450961b0383de35624015058e73bbce
|
4
|
+
data.tar.gz: fe4cd5de448b52f11b2b5d9409202ad115bb6e87d5008ed83eb3708fbd177745
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 360b2c83a7e377c2a9974cfbd812d5df0f0d3921c93aabf5b4c0426e5f7aab156fe1cd7350607be17694b243f6cc823000b8eb2bb342fb65401ce9071dcc688e
|
7
|
+
data.tar.gz: 39a199f34ca2275c4804ab1f03a0dac80105675ef43dc473f3d9d4c479b57eb7088d32a36a67a47df00ae26e1d81d3454cf0de465209d357c181cca66de18d1c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 3.10.2 (June 24, 2025)
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
- Fix incorrect in-memory counter updates on `belongs_to` association (#415)
|
5
|
+
|
6
|
+
## 3.10.1 (April 30, 2025)
|
7
|
+
|
8
|
+
Bugfixes:
|
9
|
+
- Fix issue when using `delegate` instead of `has_many :through` (#411)
|
10
|
+
|
1
11
|
## 3.10.0 (April 15, 2025)
|
2
12
|
|
3
13
|
New features:
|
@@ -138,7 +138,9 @@ module CounterCulture
|
|
138
138
|
unless Thread.current[:aggregate_counter_updates]
|
139
139
|
execute_now_or_after_commit(obj) do
|
140
140
|
klass.where(primary_key => id_to_change).update_all updates.join(', ')
|
141
|
-
|
141
|
+
unless options[:was]
|
142
|
+
assign_to_associated_object(obj, relation, change_counter_column, operator, delta_magnitude)
|
143
|
+
end
|
142
144
|
end
|
143
145
|
end
|
144
146
|
end
|
@@ -370,15 +372,31 @@ module CounterCulture
|
|
370
372
|
def assign_to_associated_object(obj, relation, change_counter_column, operator, delta_magnitude)
|
371
373
|
association_name = relation_reflect(relation).name
|
372
374
|
|
373
|
-
|
375
|
+
association_object = association_object_for_assign(obj, association_name)
|
376
|
+
return if association_object.blank?
|
374
377
|
|
375
|
-
|
376
|
-
|
377
|
-
change_counter_column
|
378
|
-
|
379
|
-
|
380
|
-
|
378
|
+
association_object.assign_attributes(
|
379
|
+
change_counter_column =>
|
380
|
+
association_object_new_counter(association_object, change_counter_column, operator, delta_magnitude)
|
381
|
+
)
|
382
|
+
association_object_clear_change(association_object, change_counter_column)
|
383
|
+
end
|
384
|
+
|
385
|
+
def association_object_for_assign(obj, association_name)
|
386
|
+
if obj.class.reflect_on_all_associations.
|
387
|
+
find { |assoc| assoc.name.to_sym == association_name.to_sym }.
|
388
|
+
blank?
|
389
|
+
# This means that this isn't defined as an association; either it
|
390
|
+
# doesn't exist at all, or it uses delegate. In either case, we can't
|
391
|
+
# update the count this way.
|
392
|
+
return
|
393
|
+
end
|
394
|
+
if !obj.association(association_name).loaded?
|
395
|
+
# If the association isn't loaded, no need to update the count
|
396
|
+
return
|
381
397
|
end
|
398
|
+
|
399
|
+
obj.public_send(association_name)
|
382
400
|
end
|
383
401
|
|
384
402
|
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.10.
|
4
|
+
version: 3.10.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: 2025-
|
11
|
+
date: 2025-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|