acts_as_paranoid 0.6.0 → 0.6.1
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 +4 -4
- data/CHANGELOG.md +32 -0
- data/README.md +8 -4
- data/lib/acts_as_paranoid.rb +1 -1
- data/lib/acts_as_paranoid/associations.rb +1 -1
- data/lib/acts_as_paranoid/core.rb +56 -12
- data/lib/acts_as_paranoid/validations.rb +10 -5
- data/lib/acts_as_paranoid/version.rb +1 -1
- data/test/test_associations.rb +46 -3
- data/test/test_core.rb +43 -0
- data/test/test_default_scopes.rb +0 -1
- data/test/test_helper.rb +26 -3
- metadata +30 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06cfbf17cb1f8fe737c00e223cc6b02f8ea1159d751c3e6c1bfba1fd077ca6ac
|
4
|
+
data.tar.gz: b887b92760729053b6286412ee861e9677c7d418bcf28bdfdc996c4e9474ed30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 699e32ad650195f1d4b34ef89e266a379ef35f450d6434d753227788fe214c3af9ebe410397799117b8b6527a240d769e768cc1a60b49f8abd663d8e1ab81ff9
|
7
|
+
data.tar.gz: a5e7745201cfe1fb5689726ca93cff4fb24a594373a10c2fb7777541f9ca7dcb2681a20ddd91692eff6dae3149b80e6a962b56dc4fecd86d10b87e77f9be1221
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
Notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## 0.6.1
|
6
|
+
|
7
|
+
* Add support for Rails 6 ([#124], by [Daniel Rice](danielricecodes),
|
8
|
+
[Josh Bryant](jbryant92), and [Romain Alexandre](RomainAlexandre))
|
9
|
+
* Add support for incrementing and decrementing counter cache columns on
|
10
|
+
associated objects ([#119], by [Dimitar Lukanov][shadydealer])
|
11
|
+
* Add `:double_tap_destroys_fully` option, with default `true` ([#116],
|
12
|
+
by [Michael Riviera][ri4a]).
|
13
|
+
* Officially support Ruby 2.6 ([#114], by [Matijs van Zuijlen][mvz]).
|
14
|
+
|
15
|
+
## 0.6.0 and earlier
|
16
|
+
|
17
|
+
(To be added)
|
18
|
+
|
19
|
+
<!-- Contributors -->
|
20
|
+
|
21
|
+
[ri4a]: https://github.com/ri4a
|
22
|
+
[mvz]: https://github.com/mvz
|
23
|
+
[shadydealer]: https://github.com/shadydealer
|
24
|
+
[danielricecodes]: https://github.com/danielricecodes
|
25
|
+
[jbryant92]: https://github.com/jbryant92
|
26
|
+
[RomainAlexandre]: https://github.com/RomainAlexandre
|
27
|
+
|
28
|
+
<!-- issues & pull requests -->
|
29
|
+
|
30
|
+
[#119]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/119
|
31
|
+
[#116]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/116
|
32
|
+
[#114]: https://github.com/ActsAsParanoid/acts_as_paranoid/pull/114
|
data/README.md
CHANGED
@@ -9,12 +9,12 @@ recoverable later.
|
|
9
9
|
|
10
10
|
## Support
|
11
11
|
|
12
|
-
**This branch targets Rails 4.2, 5.0 and 5.1, with experimental support for 5.2
|
12
|
+
**This branch targets Rails 4.2, 5.0 and 5.1, with experimental support for 5.2+**
|
13
13
|
|
14
|
-
If you're working with
|
14
|
+
If you're working with Rails 4.1-, switch to the corresponding branch, or
|
15
15
|
require an older version of the `acts_as_paranoid` gem.
|
16
16
|
|
17
|
-
### Known issues with Rails 5.2
|
17
|
+
### Known issues with Rails 5.2+
|
18
18
|
|
19
19
|
* Using acts_as_paranoid and ActiveStorage on the same model
|
20
20
|
[leads to a SystemStackError](https://github.com/ActsAsParanoid/acts_as_paranoid/issues/103).
|
@@ -114,6 +114,10 @@ p.destroy # does NOT delete the first record, just hides it
|
|
114
114
|
Paranoiac.only_deleted.where(:id => p.id).first.destroy # deletes the first record from the database
|
115
115
|
```
|
116
116
|
|
117
|
+
This behaviour can be disabled by setting the configuration option. In a future version, `false` will be the default setting.
|
118
|
+
|
119
|
+
- `:double_tap_destroys_fully => false`
|
120
|
+
|
117
121
|
### Recovery
|
118
122
|
|
119
123
|
Recovery is easy. Just invoke `recover` on it, like this:
|
@@ -263,7 +267,6 @@ child.parent_including_deleted #=> Parent (it works!)
|
|
263
267
|
|
264
268
|
Watch out for these caveats:
|
265
269
|
|
266
|
-
|
267
270
|
- You cannot use scopes named `with_deleted` and `only_deleted`
|
268
271
|
- You cannot use scopes named `deleted_inside_time_window`, `deleted_before_time`, `deleted_after_time` **if** your paranoid column's type is `time`
|
269
272
|
- You cannot name association `*_with_deleted`
|
@@ -283,5 +286,6 @@ Watch out for these caveats:
|
|
283
286
|
* To [Jean Boussier](https://github.com/byroot) for initial Rails 4.0.0 support
|
284
287
|
* To [Matijs van Zuijlen](https://github.com/mvz) for Rails 4.1 and 4.2 support
|
285
288
|
* To [Andrey Ponomarenko](https://github.com/sjke) for Rails 5 support
|
289
|
+
* To [Daniel Rice](https://github.com/danielricecodes), [Josh Bryant](https://github.com/jbryant92), and [Romain Alexandre](https://github.com/RomainAlexandre) for Rails 6.0 support.
|
286
290
|
|
287
291
|
See `LICENSE`.
|
data/lib/acts_as_paranoid.rb
CHANGED
@@ -19,7 +19,7 @@ module ActsAsParanoid
|
|
19
19
|
|
20
20
|
class_attribute :paranoid_configuration, :paranoid_column_reference
|
21
21
|
|
22
|
-
self.paranoid_configuration = { :column => "deleted_at", :column_type => "time", :recover_dependent_associations => true, :dependent_recovery_window => 2.minutes, :recovery_value => nil }
|
22
|
+
self.paranoid_configuration = { :column => "deleted_at", :column_type => "time", :recover_dependent_associations => true, :dependent_recovery_window => 2.minutes, :recovery_value => nil, double_tap_destroys_fully: true }
|
23
23
|
self.paranoid_configuration.merge!({ :deleted_value => "deleted" }) if options[:column_type] == "string"
|
24
24
|
self.paranoid_configuration.merge!({ :allow_nulls => true }) if options[:column_type] == "boolean"
|
25
25
|
self.paranoid_configuration.merge!(options) # user options
|
@@ -31,7 +31,7 @@ module ActsAsParanoid
|
|
31
31
|
association = association(:#{target})
|
32
32
|
return nil if association.options[:polymorphic] && association.klass.nil?
|
33
33
|
return #{target}_without_unscoped(*args) unless association.klass.paranoid?
|
34
|
-
association.klass.with_deleted.scoping { #{target}_without_unscoped(*args) }
|
34
|
+
association.klass.with_deleted.scoping { association.klass.unscoped { #{target}_without_unscoped(*args) } }
|
35
35
|
end
|
36
36
|
alias_method :#{target}_without_unscoped, :#{target}
|
37
37
|
alias_method :#{target}, :#{target}_with_unscoped
|
@@ -116,8 +116,14 @@ module ActsAsParanoid
|
|
116
116
|
with_transaction_returning_status do
|
117
117
|
run_callbacks :destroy do
|
118
118
|
destroy_dependent_associations!
|
119
|
-
|
120
|
-
|
119
|
+
|
120
|
+
if persisted?
|
121
|
+
# Handle composite keys, otherwise we would just use `self.class.primary_key.to_sym => self.id`.
|
122
|
+
self.class.delete_all!(Hash[[Array(self.class.primary_key), Array(self.id)].transpose])
|
123
|
+
|
124
|
+
decrement_counters_on_associations
|
125
|
+
end
|
126
|
+
|
121
127
|
self.paranoid_value = self.class.delete_now_value
|
122
128
|
freeze
|
123
129
|
end
|
@@ -128,19 +134,24 @@ module ActsAsParanoid
|
|
128
134
|
if !deleted?
|
129
135
|
with_transaction_returning_status do
|
130
136
|
run_callbacks :destroy do
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
+
|
138
|
+
if persisted?
|
139
|
+
# Handle composite keys, otherwise we would just use `self.class.primary_key.to_sym => self.id`.
|
140
|
+
self.class.delete_all(Hash[[Array(self.class.primary_key), Array(self.id)].transpose])
|
141
|
+
|
142
|
+
decrement_counters_on_associations
|
143
|
+
end
|
144
|
+
|
145
|
+
@_trigger_destroy_callback = true
|
137
146
|
|
138
147
|
self.paranoid_value = self.class.delete_now_value
|
139
148
|
self
|
140
149
|
end
|
141
150
|
end
|
142
151
|
else
|
143
|
-
|
152
|
+
if paranoid_configuration[:double_tap_destroys_fully]
|
153
|
+
destroy_fully!
|
154
|
+
end
|
144
155
|
end
|
145
156
|
end
|
146
157
|
|
@@ -155,7 +166,7 @@ module ActsAsParanoid
|
|
155
166
|
self.class.transaction do
|
156
167
|
run_callbacks :recover do
|
157
168
|
recover_dependent_associations(options[:recovery_window], options) if options[:recursive]
|
158
|
-
|
169
|
+
increment_counters_on_associations
|
159
170
|
self.paranoid_value = self.class.paranoid_configuration[:recovery_value]
|
160
171
|
self.save
|
161
172
|
end
|
@@ -169,7 +180,11 @@ module ActsAsParanoid
|
|
169
180
|
scope = klass.only_deleted
|
170
181
|
|
171
182
|
# Merge in the association's scope
|
172
|
-
scope =
|
183
|
+
scope = if ActiveRecord::VERSION::MAJOR >= 6
|
184
|
+
scope.merge(ActiveRecord::Associations::AssociationScope.scope(association(reflection.name)))
|
185
|
+
else
|
186
|
+
scope.merge(association(reflection.name).association_scope)
|
187
|
+
end
|
173
188
|
|
174
189
|
# We can only recover by window if both parent and dependant have a
|
175
190
|
# paranoid column type of :time.
|
@@ -190,7 +205,11 @@ module ActsAsParanoid
|
|
190
205
|
scope = klass.only_deleted
|
191
206
|
|
192
207
|
# Merge in the association's scope
|
193
|
-
scope =
|
208
|
+
scope = if ActiveRecord::VERSION::MAJOR >= 6
|
209
|
+
scope.merge(ActiveRecord::Associations::AssociationScope.scope(association(reflection.name)))
|
210
|
+
else
|
211
|
+
scope.merge(association(reflection.name).association_scope)
|
212
|
+
end
|
194
213
|
|
195
214
|
scope.each do |object|
|
196
215
|
object.destroy!
|
@@ -223,5 +242,30 @@ module ActsAsParanoid
|
|
223
242
|
def paranoid_value=(value)
|
224
243
|
self.send("#{self.class.paranoid_column}=", value)
|
225
244
|
end
|
245
|
+
|
246
|
+
def update_counters_on_associations method_sym
|
247
|
+
|
248
|
+
return unless [:decrement_counter, :increment_counter].include? method_sym
|
249
|
+
|
250
|
+
each_counter_cached_association_reflection do |assoc_reflection|
|
251
|
+
associated_object = send(assoc_reflection.name)
|
252
|
+
counter_cache_column = assoc_reflection.counter_cache_column
|
253
|
+
associated_object.class.send(method_sym, counter_cache_column, associated_object.id)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
def each_counter_cached_association_reflection
|
258
|
+
_reflections.each do |name, reflection|
|
259
|
+
yield reflection if reflection.belongs_to? && reflection.counter_cache_column == "#{self.class.name.underscore.pluralize}_count"
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def increment_counters_on_associations
|
264
|
+
update_counters_on_associations :increment_counter
|
265
|
+
end
|
266
|
+
|
267
|
+
def decrement_counters_on_associations
|
268
|
+
update_counters_on_associations :decrement_counter
|
269
|
+
end
|
226
270
|
end
|
227
271
|
end
|
@@ -8,10 +8,9 @@ module ActsAsParanoid
|
|
8
8
|
|
9
9
|
class UniquenessWithoutDeletedValidator
|
10
10
|
def self.[](version)
|
11
|
-
|
12
|
-
name = "V#{version.tr('.', '_')}"
|
11
|
+
name = "V#{version.to_s.tr('.', '_')}"
|
13
12
|
unless constants.include? name.to_sym
|
14
|
-
raise "Unknown validator version #{
|
13
|
+
raise "Unknown validator version #{name.inspect}; expected one of #{constants.sort.join(', ')}"
|
15
14
|
end
|
16
15
|
const_get name
|
17
16
|
end
|
@@ -38,8 +37,11 @@ module ActsAsParanoid
|
|
38
37
|
protected
|
39
38
|
|
40
39
|
def build_relation(klass, attribute, value)
|
41
|
-
|
42
|
-
|
40
|
+
if ActiveRecord::VERSION::MINOR == 0 && ActiveRecord::VERSION::MAJOR == 5
|
41
|
+
return super(klass, klass.arel_table, attribute, value)
|
42
|
+
else
|
43
|
+
super
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
@@ -75,6 +77,9 @@ module ActsAsParanoid
|
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
80
|
+
|
81
|
+
class V6 < V5
|
82
|
+
end
|
78
83
|
end
|
79
84
|
|
80
85
|
module ClassMethods
|
data/test/test_associations.rb
CHANGED
@@ -41,6 +41,48 @@ class AssociationsTest < ParanoidBaseTest
|
|
41
41
|
includes_values = ParanoidTime.includes(:not_paranoid).includes_values
|
42
42
|
|
43
43
|
assert_equal includes_values, paranoid_has_many_dependant.association(:paranoid_time_with_scope).scope.includes_values
|
44
|
+
|
45
|
+
paranoid_time = ParanoidTime.create(name: 'not-hello')
|
46
|
+
paranoid_has_many_dependant.paranoid_time = paranoid_time
|
47
|
+
paranoid_has_many_dependant.save!
|
48
|
+
|
49
|
+
assert_nil paranoid_has_many_dependant.paranoid_time_with_scope
|
50
|
+
|
51
|
+
paranoid_time.update(name: 'hello')
|
52
|
+
|
53
|
+
paranoid_has_many_dependant.reload
|
54
|
+
|
55
|
+
assert_equal paranoid_time, paranoid_has_many_dependant.paranoid_time_with_scope
|
56
|
+
|
57
|
+
paranoid_time.destroy
|
58
|
+
|
59
|
+
paranoid_has_many_dependant.reload
|
60
|
+
|
61
|
+
assert_nil paranoid_has_many_dependant.paranoid_time_with_scope
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_belongs_to_with_scope_and_deleted_option
|
65
|
+
paranoid_has_many_dependant = ParanoidHasManyDependant.new
|
66
|
+
includes_values = ParanoidTime.includes(:not_paranoid).includes_values
|
67
|
+
|
68
|
+
assert_equal includes_values, paranoid_has_many_dependant
|
69
|
+
.association(:paranoid_time_with_scope_with_deleted).scope.includes_values
|
70
|
+
|
71
|
+
paranoid_time = ParanoidTime.create(name: 'not-hello')
|
72
|
+
paranoid_has_many_dependant.paranoid_time = paranoid_time
|
73
|
+
paranoid_has_many_dependant.save!
|
74
|
+
|
75
|
+
assert_nil paranoid_has_many_dependant.paranoid_time_with_scope_with_deleted
|
76
|
+
|
77
|
+
paranoid_time.update(name: 'hello')
|
78
|
+
paranoid_has_many_dependant.reload
|
79
|
+
|
80
|
+
assert_equal paranoid_time, paranoid_has_many_dependant.paranoid_time_with_scope_with_deleted
|
81
|
+
|
82
|
+
paranoid_time.destroy
|
83
|
+
paranoid_has_many_dependant.reload
|
84
|
+
|
85
|
+
assert_equal paranoid_time, paranoid_has_many_dependant.paranoid_time_with_scope_with_deleted
|
44
86
|
end
|
45
87
|
|
46
88
|
def test_belongs_to_with_deleted
|
@@ -51,9 +93,10 @@ class AssociationsTest < ParanoidBaseTest
|
|
51
93
|
assert_equal paranoid_time, paranoid_has_many_dependant.paranoid_time_with_deleted
|
52
94
|
|
53
95
|
paranoid_time.destroy
|
96
|
+
paranoid_has_many_dependant.reload
|
54
97
|
|
55
|
-
assert_nil paranoid_has_many_dependant.
|
56
|
-
assert_equal paranoid_time, paranoid_has_many_dependant.
|
98
|
+
assert_nil paranoid_has_many_dependant.paranoid_time
|
99
|
+
assert_equal paranoid_time, paranoid_has_many_dependant.paranoid_time_with_deleted
|
57
100
|
end
|
58
101
|
|
59
102
|
def test_belongs_to_polymorphic_with_deleted
|
@@ -228,7 +271,7 @@ class AssociationsTest < ParanoidBaseTest
|
|
228
271
|
end
|
229
272
|
|
230
273
|
def test_mass_assignment_of_paranoid_column_enabled
|
231
|
-
if
|
274
|
+
if Gem.loaded_specs['activerecord'].version >= Gem::Version.new('5.2.0')
|
232
275
|
skip 'Creation as deleted is not supported with Rails >= 5.2'
|
233
276
|
end
|
234
277
|
now = Time.now
|
data/test/test_core.rb
CHANGED
@@ -437,4 +437,47 @@ class ParanoidTest < ParanoidBaseTest
|
|
437
437
|
2.times { ps.destroy }
|
438
438
|
assert_equal 0, ParanoidBooleanNotNullable.with_deleted.where(:id => ps).count
|
439
439
|
end
|
440
|
+
|
441
|
+
def test_no_double_tap_destroys_fully
|
442
|
+
ps = ParanoidNoDoubleTapDestroysFully.create!()
|
443
|
+
2.times { ps.destroy }
|
444
|
+
assert_equal 1, ParanoidNoDoubleTapDestroysFully.with_deleted.where(:id => ps).count
|
445
|
+
end
|
446
|
+
|
447
|
+
def test_decrement_counters
|
448
|
+
paranoid_boolean = ParanoidBoolean.create!()
|
449
|
+
paranoid_with_counter_cache = ParanoidWithCounterCache.create!(paranoid_boolean: paranoid_boolean)
|
450
|
+
|
451
|
+
assert_equal 1, paranoid_boolean.paranoid_with_counter_caches_count
|
452
|
+
|
453
|
+
paranoid_with_counter_cache.destroy
|
454
|
+
|
455
|
+
assert_equal 0, paranoid_boolean.reload.paranoid_with_counter_caches_count
|
456
|
+
end
|
457
|
+
|
458
|
+
def test_hard_destroy_decrement_counters
|
459
|
+
paranoid_boolean = ParanoidBoolean.create!()
|
460
|
+
paranoid_with_counter_cache = ParanoidWithCounterCache.create!(paranoid_boolean: paranoid_boolean)
|
461
|
+
|
462
|
+
assert_equal 1, paranoid_boolean.paranoid_with_counter_caches_count
|
463
|
+
|
464
|
+
paranoid_with_counter_cache.destroy_fully!
|
465
|
+
|
466
|
+
assert_equal 0, paranoid_boolean.reload.paranoid_with_counter_caches_count
|
467
|
+
end
|
468
|
+
|
469
|
+
def test_increment_counters
|
470
|
+
paranoid_boolean = ParanoidBoolean.create!()
|
471
|
+
paranoid_with_counter_cache = ParanoidWithCounterCache.create!(paranoid_boolean: paranoid_boolean)
|
472
|
+
|
473
|
+
assert_equal 1, paranoid_boolean.paranoid_with_counter_caches_count
|
474
|
+
|
475
|
+
paranoid_with_counter_cache.destroy
|
476
|
+
|
477
|
+
assert_equal 0, paranoid_boolean.reload.paranoid_with_counter_caches_count
|
478
|
+
|
479
|
+
paranoid_with_counter_cache.recover
|
480
|
+
|
481
|
+
assert_equal 1, paranoid_boolean.reload.paranoid_with_counter_caches_count
|
482
|
+
end
|
440
483
|
end
|
data/test/test_default_scopes.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -31,7 +31,7 @@ def setup_db
|
|
31
31
|
t.string :name
|
32
32
|
t.boolean :is_deleted
|
33
33
|
t.integer :paranoid_time_id
|
34
|
-
|
34
|
+
t.integer :paranoid_with_counter_caches_count
|
35
35
|
timestamps t
|
36
36
|
end
|
37
37
|
|
@@ -148,7 +148,7 @@ def setup_db
|
|
148
148
|
timestamps t
|
149
149
|
end
|
150
150
|
|
151
|
-
|
151
|
+
create_table :paranoid_forests do |t|
|
152
152
|
t.string :name
|
153
153
|
t.boolean :rainforest
|
154
154
|
t.datetime :deleted_at
|
@@ -208,6 +208,18 @@ def setup_db
|
|
208
208
|
|
209
209
|
timestamps t
|
210
210
|
end
|
211
|
+
|
212
|
+
create_table :paranoid_no_double_tap_destroys_fullies do |t|
|
213
|
+
t.datetime :deleted_at
|
214
|
+
end
|
215
|
+
|
216
|
+
create_table :paranoid_with_counter_caches do |t|
|
217
|
+
t.string :name
|
218
|
+
t.datetime :deleted_at
|
219
|
+
t.integer :paranoid_boolean_id
|
220
|
+
|
221
|
+
timestamps t
|
222
|
+
end
|
211
223
|
end
|
212
224
|
end
|
213
225
|
|
@@ -247,6 +259,7 @@ class ParanoidBoolean < ActiveRecord::Base
|
|
247
259
|
|
248
260
|
belongs_to :paranoid_time
|
249
261
|
has_one :paranoid_has_one_dependant, :dependent => :destroy
|
262
|
+
has_many :paranoid_with_counter_cache, :dependent => :destroy
|
250
263
|
end
|
251
264
|
|
252
265
|
class ParanoidString < ActiveRecord::Base
|
@@ -256,6 +269,10 @@ end
|
|
256
269
|
class NotParanoid < ActiveRecord::Base
|
257
270
|
end
|
258
271
|
|
272
|
+
class ParanoidNoDoubleTapDestroysFully < ActiveRecord::Base
|
273
|
+
acts_as_paranoid :double_tap_destroys_fully => false
|
274
|
+
end
|
275
|
+
|
259
276
|
class HasOneNotParanoid < ActiveRecord::Base
|
260
277
|
belongs_to :paranoid_time, :with_deleted => true
|
261
278
|
end
|
@@ -265,11 +282,17 @@ class DoubleHasOneNotParanoid < HasOneNotParanoid
|
|
265
282
|
belongs_to :paranoid_time, :with_deleted => true
|
266
283
|
end
|
267
284
|
|
285
|
+
class ParanoidWithCounterCache < ActiveRecord::Base
|
286
|
+
acts_as_paranoid
|
287
|
+
belongs_to :paranoid_boolean, :counter_cache => true
|
288
|
+
end
|
289
|
+
|
268
290
|
class ParanoidHasManyDependant < ActiveRecord::Base
|
269
291
|
acts_as_paranoid
|
270
292
|
belongs_to :paranoid_time
|
271
|
-
belongs_to :paranoid_time_with_scope, -> { includes(:not_paranoid) }, :class_name => 'ParanoidTime', :foreign_key => :paranoid_time_id
|
293
|
+
belongs_to :paranoid_time_with_scope, -> { where(name: 'hello').includes(:not_paranoid) }, :class_name => 'ParanoidTime', :foreign_key => :paranoid_time_id
|
272
294
|
belongs_to :paranoid_time_with_deleted, :class_name => 'ParanoidTime', :foreign_key => :paranoid_time_id, :with_deleted => true
|
295
|
+
belongs_to :paranoid_time_with_scope_with_deleted, -> { where(name: 'hello').includes(:not_paranoid) }, :class_name => 'ParanoidTime', :foreign_key => :paranoid_time_id, :with_deleted => true
|
273
296
|
belongs_to :paranoid_time_polymorphic_with_deleted, :class_name => 'ParanoidTime', :foreign_key => :paranoid_time_id, :polymorphic => true, :with_deleted => true
|
274
297
|
|
275
298
|
belongs_to :paranoid_belongs_dependant, :dependent => :destroy
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_paranoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Scott
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2019-09-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '4.2'
|
22
22
|
- - "<"
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: '
|
24
|
+
version: '7.0'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
version: '4.2'
|
32
32
|
- - "<"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '7.0'
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: activesupport
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,7 +41,7 @@ dependencies:
|
|
41
41
|
version: '4.2'
|
42
42
|
- - "<"
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
44
|
+
version: '7.0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
47
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -51,21 +51,27 @@ dependencies:
|
|
51
51
|
version: '4.2'
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '7.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.5'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '3.0'
|
62
65
|
type: :development
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
|
-
- - "
|
69
|
+
- - ">="
|
67
70
|
- !ruby/object:Gem::Version
|
68
71
|
version: '1.5'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: rake
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +120,20 @@ dependencies:
|
|
114
120
|
- - "<="
|
115
121
|
- !ruby/object:Gem::Version
|
116
122
|
version: '6.0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: pry
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
type: :development
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
117
137
|
description: Check the home page for more in-depth information.
|
118
138
|
email:
|
119
139
|
- e@zzak.io
|
@@ -121,6 +141,7 @@ executables: []
|
|
121
141
|
extensions: []
|
122
142
|
extra_rdoc_files: []
|
123
143
|
files:
|
144
|
+
- CHANGELOG.md
|
124
145
|
- LICENSE
|
125
146
|
- README.md
|
126
147
|
- lib/acts_as_paranoid.rb
|
@@ -157,8 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
178
|
- !ruby/object:Gem::Version
|
158
179
|
version: '0'
|
159
180
|
requirements: []
|
160
|
-
|
161
|
-
rubygems_version: 2.7.6
|
181
|
+
rubygems_version: 3.0.6
|
162
182
|
signing_key:
|
163
183
|
specification_version: 4
|
164
184
|
summary: Active Record plugin which allows you to hide and restore records without
|