active_archive 4.0.2 → 4.0.3

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
  SHA1:
3
- metadata.gz: af67b471ff812548802cf841ac32bd3186e5b4dc
4
- data.tar.gz: 2c4e302d7542347ed0cbbfee4b9ce1079150200b
3
+ metadata.gz: 864f0d72e7dfd6798436108e50a06e302cdc6e10
4
+ data.tar.gz: 2bec4eea982a712c349f9f9bd93e4fe8a617993c
5
5
  SHA512:
6
- metadata.gz: ac905b798f7353d1122e7122d382a00297e1d78b21e60e6ae24118e3c5129ff410cea3251d965d646bb5e73978f09094e6387223b66137c35317ac21904d9946
7
- data.tar.gz: '086fdc5175d7fbc3e2efcb93c1e4f19b9261fe31bf96b590f1e892c6251214cbbbfa73d9bae030f0717fbc0fd1edda987d23b638bbcea0a6db4bbb5490be6450'
6
+ metadata.gz: 41a063fb155b91ff2ce1606cb4fc28fff4afbff2c791f6ace986832f705422a8602480e116b2a22ef3c134b19878bc3c18b377909b7d118a49214747bb20c414
7
+ data.tar.gz: 071c2c2fa40f486a9f7aef3c640bba9245f06d5587b3326c3dd3cbf483e51bc4b0050f4d7459eaab4fabba00dff060866f0f2de17fdb4be346c69fe0eb64eec1
@@ -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 { |record| record.call(opts) }
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, reflection|
79
- next unless reflection.options[:dependent] == :destroy
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 { |record| record.unarchive(force) }
142
+ dependent_records_for_unarchival(name, ref).each { |rec| rec.try(:unarchive, force) }
143
+ reload
141
144
  end
142
145
  end
143
146
 
@@ -2,7 +2,7 @@ module ActiveArchive
2
2
  module Methods
3
3
 
4
4
  def archivable?
5
- columns.detect { |column| column.name == 'archived_at' }
5
+ columns.detect { |col| col.name == 'archived_at' }
6
6
  end
7
7
 
8
8
  def archive_all(conditions = nil)
@@ -9,11 +9,11 @@ module ActiveArchive
9
9
  end
10
10
  end
11
11
 
12
- protected
13
-
14
- def path(locale)
12
+ def self.path(locale)
15
13
  File.expand_path("../../config/locales/#{locale}.yml", __FILE__)
16
14
  end
17
15
 
16
+ private_class_method :path
17
+
18
18
  end
19
19
  end
@@ -8,10 +8,9 @@ module ActiveArchive
8
8
  column(:created_at, :datetime, options)
9
9
  column(:updated_at, :datetime, options)
10
10
 
11
- if ActiveArchive::Settings.config.all_records_archivable == true
12
- options[:null] = true
13
- column(:archived_at, :datetime, options)
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
@@ -1,3 +1,3 @@
1
1
  module ActiveArchive
2
- VERSION = '4.0.2'.freeze
2
+ VERSION = '4.0.3'.freeze
3
3
  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.2
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-09-08 00:00:00.000000000 Z
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.4
236
+ rubygems_version: 2.6.6
237
237
  signing_key:
238
238
  specification_version: 4
239
239
  summary: Gem for soft-deleting ActiveRecord objects.