active_archive 4.0.2 → 4.0.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 864f0d72e7dfd6798436108e50a06e302cdc6e10
|
4
|
+
data.tar.gz: 2bec4eea982a712c349f9f9bd93e4fe8a617993c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41a063fb155b91ff2ce1606cb4fc28fff4afbff2c791f6ace986832f705422a8602480e116b2a22ef3c134b19878bc3c18b377909b7d118a49214747bb20c414
|
7
|
+
data.tar.gz: 071c2c2fa40f486a9f7aef3c640bba9245f06d5587b3326c3dd3cbf483e51bc4b0050f4d7459eaab4fabba00dff060866f0f2de17fdb4be346c69fe0eb64eec1
|
data/lib/active_archive/base.rb
CHANGED
@@ -36,7 +36,7 @@ module ActiveArchive
|
|
36
36
|
def unarchive(opts = nil)
|
37
37
|
with_transaction_returning_status do
|
38
38
|
records = should_unarchive_parent_first?(opts) ? unarchival.reverse : unarchival
|
39
|
-
records.each { |
|
39
|
+
records.each { |rec| rec.call(opts) }
|
40
40
|
|
41
41
|
self
|
42
42
|
end
|
@@ -75,8 +75,8 @@ module ActiveArchive
|
|
75
75
|
def retrieve_dependent_records
|
76
76
|
dependent_records = {}
|
77
77
|
|
78
|
-
self.class.reflections.each do |key,
|
79
|
-
next unless
|
78
|
+
self.class.reflections.each do |key, ref|
|
79
|
+
next unless ref.options[:dependent] == :destroy
|
80
80
|
|
81
81
|
records = send(key)
|
82
82
|
next unless records
|
@@ -120,24 +120,27 @@ module ActiveArchive
|
|
120
120
|
]
|
121
121
|
end
|
122
122
|
|
123
|
+
# rubocop:disable Metrics/LineLength
|
123
124
|
def dependent_records_for_unarchival(name, reflection)
|
124
125
|
record = send(name)
|
125
126
|
|
126
127
|
case reflection.macro.to_s.gsub('has_', '').to_sym
|
127
128
|
when :many
|
128
|
-
records = archived_at ? set_record_window(record, name, reflection) : record
|
129
|
+
records = archived_at ? set_record_window(record, name, reflection) : record.unscope(where: :archived_at)
|
129
130
|
when :one, :belongs_to
|
130
131
|
self.class.unscoped { records = [] << record }
|
131
132
|
end
|
132
133
|
|
133
134
|
[records].flatten.compact
|
134
135
|
end
|
136
|
+
# rubocop:enable Metrics/LineLength
|
135
137
|
|
136
138
|
def unarchive_destroyed_dependent_records(force = nil)
|
137
139
|
self.class.reflections
|
138
140
|
.select { |_, ref| 'destroy' == ref.options[:dependent].to_s && ref.klass.archivable? }
|
139
141
|
.each do |name, ref|
|
140
|
-
dependent_records_for_unarchival(name, ref).each { |
|
142
|
+
dependent_records_for_unarchival(name, ref).each { |rec| rec.try(:unarchive, force) }
|
143
|
+
reload
|
141
144
|
end
|
142
145
|
end
|
143
146
|
|
@@ -8,10 +8,9 @@ module ActiveArchive
|
|
8
8
|
column(:created_at, :datetime, options)
|
9
9
|
column(:updated_at, :datetime, options)
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
11
|
+
return unless ActiveArchive::Settings.config.all_records_archivable == true
|
12
|
+
options[:null] = true
|
13
|
+
column(:archived_at, :datetime, options)
|
15
14
|
end
|
16
15
|
|
17
16
|
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: 4.0.
|
4
|
+
version: 4.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
233
|
version: '0'
|
234
234
|
requirements: []
|
235
235
|
rubyforge_project:
|
236
|
-
rubygems_version: 2.6.
|
236
|
+
rubygems_version: 2.6.6
|
237
237
|
signing_key:
|
238
238
|
specification_version: 4
|
239
239
|
summary: Gem for soft-deleting ActiveRecord objects.
|