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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 282c657f059578c3f1771526ee61558e0d3b000740e7efd93d948330b34f89ab
4
- data.tar.gz: c08408178d8f7738f1157154800bbdd967b6a1d1613dd9571efaf94bac1bde0d
3
+ metadata.gz: 5506e5337187ed5218702b644331efa366c60c44aec95f04825a53961915a138
4
+ data.tar.gz: 347f68b2b28c200090dbda43423bfc8647757b4d992b2f3b4e97d91dc8820a30
5
5
  SHA512:
6
- metadata.gz: 35268ef2457411db9f30c38923e330e53eed19185b2d87a5c2795492edcf37a27c0fb42341cdc6df31b741eb18779c3466018ec0507ee29fd91649cddc5bef36
7
- data.tar.gz: 1d2359812759d3e3cf2ec97d94108f9c478560ff6a01919c35cfb35a45f72f4b0a09b10b5f2ed834463b77fd511853cbdd6cf0b887e35505fb97421d0c23cd9b
6
+ metadata.gz: a73ad42afa55fee0e6628d82e0e484ed8064e2eed19a80f053a47a35d13e21086f82d4fed1771a14c445aec653d342f67f3927abf3e2e17797b847d9404228b2
7
+ data.tar.gz: '096868b1dc4e290062767e4b7574fe90512933b22c710964ff980b5d61c9e781123bd2742edc64a853a83e4f371b3687c117ce02de2aa742b9c6875a66d408de'
@@ -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.send :include, ActiveArchive::Base
253
+ ActiveRecord::Base.include(ActiveArchive::Base)
236
254
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveArchive
4
- VERSION ||= '5.2.2'
4
+ VERSION ||= '5.3.0'
5
5
  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.2.2
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-08 00:00:00.000000000 Z
11
+ date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails