active_archive 5.2.2 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_archive/base.rb +19 -1
- data/lib/active_archive/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: 5506e5337187ed5218702b644331efa366c60c44aec95f04825a53961915a138
|
4
|
+
data.tar.gz: 347f68b2b28c200090dbda43423bfc8647757b4d992b2f3b4e97d91dc8820a30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a73ad42afa55fee0e6628d82e0e484ed8064e2eed19a80f053a47a35d13e21086f82d4fed1771a14c445aec653d342f67f3927abf3e2e17797b847d9404228b2
|
7
|
+
data.tar.gz: '096868b1dc4e290062767e4b7574fe90512933b22c710964ff980b5d61c9e781123bd2742edc64a853a83e4f371b3687c117ce02de2aa742b9c6875a66d408de'
|
data/lib/active_archive/base.rb
CHANGED
@@ -45,6 +45,12 @@ module ActiveArchive
|
|
45
45
|
permanently_delete_records_after { super() }
|
46
46
|
else
|
47
47
|
destroy_with_active_archive(force)
|
48
|
+
|
49
|
+
if ::ActiveRecord::VERSION::MAJOR >= 5
|
50
|
+
archived_at_will_change!
|
51
|
+
elsif ::ActiveRecord::VERSION::MAJOR >= 4
|
52
|
+
attribute_will_change!('archived_at')
|
53
|
+
end
|
48
54
|
end
|
49
55
|
end
|
50
56
|
end
|
@@ -80,9 +86,18 @@ module ActiveArchive
|
|
80
86
|
self.class.unscoped.find(id)
|
81
87
|
end
|
82
88
|
|
89
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
83
90
|
def set_archived_at(value, force = nil)
|
84
91
|
return self unless archivable?
|
92
|
+
|
85
93
|
record = get_archived_record
|
94
|
+
|
95
|
+
if ::ActiveRecord::VERSION::MAJOR >= 5
|
96
|
+
record.archived_at_will_change!
|
97
|
+
elsif ::ActiveRecord::VERSION::MAJOR >= 4
|
98
|
+
record.attribute_will_change!('archived_at')
|
99
|
+
end
|
100
|
+
|
86
101
|
record.archived_at = value
|
87
102
|
|
88
103
|
begin
|
@@ -104,6 +119,7 @@ module ActiveArchive
|
|
104
119
|
raise error
|
105
120
|
end
|
106
121
|
end
|
122
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
107
123
|
|
108
124
|
def each_counter_cache
|
109
125
|
_reflections.each do |name, reflection|
|
@@ -182,6 +198,7 @@ module ActiveArchive
|
|
182
198
|
dependent_reflections(self.class).reduce({}) do |records, (key, _)|
|
183
199
|
found = Array(send(key)).compact
|
184
200
|
next records if found.empty?
|
201
|
+
|
185
202
|
records.update(found.first.class => found.map(&:id))
|
186
203
|
end
|
187
204
|
end
|
@@ -198,6 +215,7 @@ module ActiveArchive
|
|
198
215
|
ids.each do |id|
|
199
216
|
record = klass.unscoped.where(klass.primary_key => id).first
|
200
217
|
next unless record
|
218
|
+
|
201
219
|
record.archived_at = nil
|
202
220
|
record.destroy(:force)
|
203
221
|
end
|
@@ -232,5 +250,5 @@ module ActiveArchive
|
|
232
250
|
end
|
233
251
|
|
234
252
|
ActiveSupport.on_load(:active_record) do
|
235
|
-
ActiveRecord::Base.
|
253
|
+
ActiveRecord::Base.include(ActiveArchive::Base)
|
236
254
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|