soft_deletion 1.8.0 → 1.10.0
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/soft_deletion/core.rb +18 -7
- data/lib/soft_deletion/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 558cebd07c91a09e4e4c8ed9666ec2e69f976f683638808587dd82a14a26b1a0
|
4
|
+
data.tar.gz: 70c40697c87ab55a54631b6157b60931e0955fd41a2211ab8d03a4560b790e0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 188f18ba4882573c43409d0459bfd5f8241309d442d5cc4c928c15751952996851616b469b6ba4d40381d16d215a06d2bb80496044cf9efdcd5a37af9c1a9b3d
|
7
|
+
data.tar.gz: 2ea4e5a90ff792fad51ea8798d50ec96e1bb3099dde6cdf37a04775752e57220d43b6bc10370be1510280d738453e69de7da144d82e782fde4d2af45f1f12d20
|
data/lib/soft_deletion/core.rb
CHANGED
@@ -86,14 +86,25 @@ module SoftDeletion
|
|
86
86
|
|
87
87
|
protected
|
88
88
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
target = association.target
|
94
|
-
target.class.update_counters(target.id, association.reflection.counter_cache_column => value)
|
89
|
+
if ActiveRecord.version >= Gem::Version.new("7.2.0")
|
90
|
+
def update_soft_delete_counter_caches(value) # uncovered NOTE: covered only at Rails >= 7.2.0 tests
|
91
|
+
counter_cached_association_names.each do |association_name| # uncovered
|
92
|
+
update_soft_delete_counter_cache(association(association_name), value) # uncovered
|
95
93
|
end
|
96
94
|
end
|
95
|
+
else
|
96
|
+
def update_soft_delete_counter_caches(value) # uncovered NOTE: covered only at Rails < 7.2.0 tests
|
97
|
+
each_counter_cached_associations do |association| # uncovered
|
98
|
+
update_soft_delete_counter_cache(association, value) # uncovered
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def update_soft_delete_counter_cache(association, value)
|
104
|
+
association.load_target unless association.loaded?
|
105
|
+
if (target = association.target) # uncovered TODO: add test coverage for target not existing
|
106
|
+
target.class.update_counters(target.id, association.reflection.counter_cache_column => value)
|
107
|
+
end
|
97
108
|
end
|
98
109
|
|
99
110
|
def _run_soft_delete(method, *args, **kwargs, &block)
|
@@ -115,7 +126,7 @@ module SoftDeletion
|
|
115
126
|
end
|
116
127
|
|
117
128
|
def _run_soft_undelete(&block)
|
118
|
-
raise "#{self.class} is not deleted" unless deleted_at
|
129
|
+
raise "#{self.class} is not deleted" unless deleted_at # uncovered TODO: add test coverage
|
119
130
|
|
120
131
|
result = false
|
121
132
|
limit = deleted_at - 1.hour
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soft_deletion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 5.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '7.
|
22
|
+
version: '7.3'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 5.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '7.
|
32
|
+
version: '7.3'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
162
|
+
rubygems_version: 3.4.10
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: Explicit soft deletion for ActiveRecord via deleted_at and default scope.
|