paranoia 2.6.0 → 2.6.2

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
  SHA256:
3
- metadata.gz: ad52996a9a12b6605d8179ad1ae5ef39cb7655d19d037884518800a02f6ff160
4
- data.tar.gz: 3c9d2c4203e203b64bf0e24db1995ddfc431c8ed742ad96319f19eea2a62bc8a
3
+ metadata.gz: 5435d5ed0b4879dda1edf99c6cebfa860d8ae87a7420dea64289b6f53fc48314
4
+ data.tar.gz: af9635bbfa0477de0acf5cf18160b28e4f7e18ed0e41f551ae9e8a63146d3083
5
5
  SHA512:
6
- metadata.gz: ed7a78d7135fce0a513e0f5fb4c6c685c99ad788efa57e15dd9ae011d1dfce0d98bc41fd49b7688f3d706e6101b78824ada19ce3617359a085186e76acc0a2db
7
- data.tar.gz: 2a24bfb1f5d1f9b8c5e588c86bf745ed80125167dfefc6ad5a10cc3b7a66da3ee50f85b7727cda74a5f92a9a1d1b3fac0defc4296b71b1dd7f8c9e9d8496831f
6
+ metadata.gz: 1a8b413670e0cfc193cb061ff7a9f4edec3765bfde3c4e3f37e43ecc0136f7adecf6ffb0ba5ee29791949e98b4a07daa0bdc58cbcd9c0ee30e13daddd9c4a3b9
7
+ data.tar.gz: 893ade53cdf583809902904061b8deae5a337042b41df30c373937b29fa310ea9945dd494b35ae566d52005f672bf1d4529d458c684a12a0226a0197898a5b2d
@@ -15,40 +15,30 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby:
19
- - 3.1
20
- - '3.0'
21
- - 2.7
22
- - 2.6
23
- - 2.5
24
- # - jruby-9.2.19.0
25
- # - jruby-9.3.1.0
26
- rails:
27
- - '~> 5.1.0'
28
- - '~> 5.2.0'
29
- - '~> 6.0.0'
30
- - '~> 6.1.0'
31
- - '~> 7.0.0'
32
- - 'edge'
33
- exclude:
34
- # Rails edge is now 7.x and requires ruby 2.7
35
- - rails: 'edge'
36
- ruby: 2.6
37
- - rails: 'edge'
38
- ruby: 2.5
39
- - rails: '~> 7.0.0'
40
- ruby: 2.6
41
- - rails: '~> 7.0.0'
42
- ruby: 2.5
43
- # Legacy Rails with newer rubies
44
- - rails: '~> 5.1.0'
45
- ruby: '3.0'
46
- - rails: '~> 5.2.0'
47
- ruby: '3.0'
48
- - rails: '~> 5.1.0'
49
- ruby: 3.1
50
- - rails: '~> 5.2.0'
51
- ruby: 3.1
18
+ rails: ["~> 7.0.0", "~> 6.1.0", "~> 6.0.0"]
19
+ ruby: ["3.2.2", "3.1.4", "3.0.6", "2.7.8"]
20
+ include:
21
+ - ruby: 3.2
22
+ rails: 'edge'
23
+ # single test failure with jruby
24
+ #- ruby: jruby-9.4
25
+ # rails: '~> 7.0.0'
26
+ - ruby: 2.6
27
+ rails: '~> 6.1.0'
28
+ - ruby: 2.6
29
+ rails: '~> 6.0.0'
30
+ - ruby: 2.6
31
+ rails: '~> 5.2.0'
32
+ - ruby: 2.6
33
+ rails: '~> 5.1.0'
34
+ - ruby: 2.5
35
+ rails: '~> 6.0.0'
36
+ - ruby: 2.5
37
+ rails: '~> 5.2.0'
38
+ - ruby: 2.5
39
+ rails: '~> 5.1.0'
40
+ #os: ubuntu-latest
41
+ #arch: x64
52
42
 
53
43
  env:
54
44
  RAILS: ${{ matrix.rails }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # paranoia Changelog
2
2
 
3
+ ## 2.6.2
4
+
5
+ * [#441](https://github.com/rubysherpas/paranoia/pull/441) Recursive restore with has_many/one through assocs (#441)
6
+ [Emil Ong](https://github.com/emilong)
7
+
8
+ ## 2.6.1
9
+
10
+ * [#535](https://github.com/rubysherpas/paranoia/pull/535) Allow to skip updating paranoia_destroy_attributes for records while really_destroy!
11
+ [Anton Bogdanov](https://github.com/kortirso)
12
+
3
13
  ## 2.6.0
4
14
 
5
15
  * [#512](https://github.com/rubysherpas/paranoia/pull/512) Quote table names; Mysql 8 has keywords that might match table names which cause an exception.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/paranoia.svg)](https://badge.fury.io/rb/paranoia)
2
2
  [![build](https://github.com/rubysherpas/paranoia/actions/workflows/build.yml/badge.svg)](https://github.com/rubysherpas/paranoia/actions/workflows/build.yml)
3
3
 
4
- **Notice:**
4
+ **Notice:**
5
5
 
6
6
  `paranoia` has some surprising behaviour (like overriding ActiveRecord's `delete` and `destroy`) and is not recommended for new projects. See [`discard`'s README](https://github.com/jhawthorn/discard#why-not-paranoia-or-acts_as_paranoid) for more details.
7
7
 
@@ -103,6 +103,14 @@ If you really want it gone *gone*, call `really_destroy!`:
103
103
  # => client
104
104
  ```
105
105
 
106
+ If you need skip updating timestamps for deleting records, call `really_destroy!(update_destroy_attributes: false)`.
107
+ When we call `really_destroy!(update_destroy_attributes: false)` on the parent `client`, then each child `email` will also have `really_destroy!(update_destroy_attributes: false)` called.
108
+
109
+ ``` ruby
110
+ >> client.really_destroy!(update_destroy_attributes: false)
111
+ # => client
112
+ ```
113
+
106
114
  If you want to use a column other than `deleted_at`, you can pass it as an option:
107
115
 
108
116
  ``` ruby
@@ -1,3 +1,3 @@
1
1
  module Paranoia
2
- VERSION = '2.6.0'.freeze
2
+ VERSION = '2.6.2'.freeze
3
3
  end
data/lib/paranoia.rb CHANGED
@@ -144,7 +144,7 @@ module Paranoia
144
144
  end
145
145
  alias :deleted? :paranoia_destroyed?
146
146
 
147
- def really_destroy!
147
+ def really_destroy!(update_destroy_attributes: true)
148
148
  with_transaction_returning_status do
149
149
  run_callbacks(:real_destroy) do
150
150
  @_disable_counter_cache = paranoia_destroyed?
@@ -158,12 +158,14 @@ module Paranoia
158
158
  # .paranoid? will work for both instances and classes
159
159
  next unless association_data && association_data.paranoid?
160
160
  if reflection.collection?
161
- next association_data.with_deleted.each(&:really_destroy!)
161
+ next association_data.with_deleted.find_each { |record|
162
+ record.really_destroy!(update_destroy_attributes: update_destroy_attributes)
163
+ }
162
164
  end
163
- association_data.really_destroy!
165
+ association_data.really_destroy!(update_destroy_attributes: update_destroy_attributes)
164
166
  end
165
167
  end
166
- update_columns(paranoia_destroy_attributes)
168
+ update_columns(paranoia_destroy_attributes) if update_destroy_attributes
167
169
  destroy_without_paranoia
168
170
  end
169
171
  end
@@ -215,7 +217,12 @@ module Paranoia
215
217
 
216
218
  if association_data.nil? && association.macro.to_s == "has_one"
217
219
  association_class_name = association.klass.name
218
- association_foreign_key = association.foreign_key
220
+
221
+ association_foreign_key = if association.options[:through].present?
222
+ association.klass.primary_key
223
+ else
224
+ association.foreign_key
225
+ end
219
226
 
220
227
  if association.type
221
228
  association_polymorphic_type = association.type
@@ -224,7 +231,7 @@ module Paranoia
224
231
  association_find_conditions = { association_foreign_key => self.id }
225
232
  end
226
233
 
227
- association_class = association_class_name.constantize
234
+ association_class = association.klass
228
235
  if association_class.paranoid?
229
236
  association_class.only_deleted.where(association_find_conditions).first
230
237
  .try!(:restore, recursive: true, :recovery_window_range => recovery_window_range)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paranoia
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - radarlistener@gmail.com
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-23 00:00:00.000000000 Z
11
+ date: 2023-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -91,7 +91,7 @@ homepage: https://github.com/rubysherpas/paranoia
91
91
  licenses:
92
92
  - MIT
93
93
  metadata: {}
94
- post_install_message:
94
+ post_install_message:
95
95
  rdoc_options: []
96
96
  require_paths:
97
97
  - lib
@@ -106,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: 1.3.6
108
108
  requirements: []
109
- rubygems_version: 3.1.6
110
- signing_key:
109
+ rubygems_version: 3.4.11
110
+ signing_key:
111
111
  specification_version: 4
112
112
  summary: Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5,
113
113
  using much, much, much less code.