undeletable 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/undeletable.rb +5 -3
- data/lib/undeletable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDE0YzUzYWUxM2U1ODcwOWQyNWYzYWJmNWJjMDExM2RmNmE2NDc1Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2YzNTk1ZTFkZDBlYWEwNjc3OTdiNTJjMTA4NjljZDM2MTdkNDIyNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjdlMDRlMmFiOGE3OGI4NzgwYzhiYzI1ZDhlZjRkNzU0YWZiMzUyOWY1ODU2
|
10
|
+
Y2MzNzZkNjk3ZTRkMmYzZjgwZTljMzI0NmFjYWJmN2U3Y2E3NWFlNGU0YzY3
|
11
|
+
ZGFlODFlNWRlZTZjZTZkZWY1YjA0MzhlYTAzZDlmNGQwZmExZTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmQxOTE5MjZiZTM4YzIyY2MzMzliMjYzOWUyN2Q1NjdlMzc2OGY2YTVhYzVi
|
14
|
+
ZWJjMTI2YjM1YWI1MjNlNjllOWExYTA0YzU1NzczYzYwMjY2NjYxZWUxMTY5
|
15
|
+
OGQzNDAzNDE5NDc3MTU2ZGQ3NzUyOTE5NzIwZGRjYjBlNDMzZmY=
|
data/lib/undeletable.rb
CHANGED
@@ -73,8 +73,12 @@ class ActiveRecord::Relation
|
|
73
73
|
if klass.respond_to?(:undeletable?) && klass.undeletable?
|
74
74
|
raise ActiveRecord::ReadOnlyRecord.new("#{self} is undeletable") if klass.raise_on_delete?
|
75
75
|
logger.debug("will not #{self}.destroy_all", e) if Undeletable.debug
|
76
|
-
if
|
76
|
+
if args.length > 0 && block_given?
|
77
77
|
where(*args, &block).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset }
|
78
|
+
elsif args.length > 0 && !block_given?
|
79
|
+
where(*args).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset }
|
80
|
+
elsif args.length == 0 && block_given?
|
81
|
+
where(&block).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset }
|
78
82
|
else
|
79
83
|
to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset }
|
80
84
|
end
|
@@ -113,8 +117,6 @@ class ActiveRecord::Base
|
|
113
117
|
private
|
114
118
|
|
115
119
|
def self.undeletable_init(raise_on_delete_val)
|
116
|
-
class_attribute :undeletable_enabled, instance_writer: true
|
117
|
-
self.undeletable_enabled = true
|
118
120
|
class_attribute :raise_on_delete, instance_writer: true
|
119
121
|
self.raise_on_delete = raise_on_delete_val
|
120
122
|
class << self
|
data/lib/undeletable/version.rb
CHANGED