rails_soft_deletable 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/rails_soft_deletable/callbacks.rb +7 -7
- data/lib/rails_soft_deletable/query.rb +3 -1
- data/lib/rails_soft_deletable/rails/active_record.rb +1 -1
- data/lib/rails_soft_deletable/version.rb +1 -1
- data/spec/dummy/app/models/decimal_model.rb +2 -0
- data/spec/dummy/app/models/integer_model.rb +3 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +1131 -759
- data/spec/rails_helper.rb +37 -0
- data/spec/rails_soft_deletable_spec.rb +38 -2
- data/spec/spec_helper.rb +57 -16
- metadata +61 -37
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzMzYzk5MzBhMWI5OTM3ZjI4MGNmNWY2M2YzNTNlNjI1ZjMwMTZlMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2EyOTgzYmQ5ZmQ0OGE0MTA4MDQxMWY4YWRlMTMzODBhMGEwYTk3MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWNiN2EyMWY0YTNlZTZjYzgwMTkzZDYxMTgwODIxODY2MmFmZGVjNjRmNTYx
|
10
|
+
YTdiZDRlZjllNWFiZmY2NzA2NDAzZmJkMDZmNWIxZjg4MDUyMDYxNzhkNjFl
|
11
|
+
ZDRiZGRkZjAwODcyYTlhN2Y1ZDAwMjM5MmMyY2RmNmJhY2VlMzM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDAzZjUxODlkMzBjMDEwOTMzZmIzZjY3YTlhODdjYjA2NTQwOTZjYWM4ZmQ0
|
14
|
+
ZWY0NjgyYjRhNjA5MWE2YmM2ODQzOWQ5NTM5MDk3NzAwMjU3ZDJiOTJiM2Nh
|
15
|
+
ODdjYWQzNjAzOTAyMTM5YWMyZjM5MTUyOGYzY2UwODNmMjJiYWY=
|
@@ -7,16 +7,16 @@ module RailsSoftDeletable
|
|
7
7
|
included do
|
8
8
|
define_callbacks :restore
|
9
9
|
|
10
|
-
define_singleton_method("before_restore") do |*args,
|
11
|
-
set_callback(:restore, :before, *args,
|
10
|
+
define_singleton_method("before_restore") do |*args, block|
|
11
|
+
set_callback(:restore, :before, *args, block)
|
12
12
|
end
|
13
13
|
|
14
|
-
define_singleton_method("around_restore") do |*args,
|
15
|
-
set_callback(:restore, :around, *args,
|
14
|
+
define_singleton_method("around_restore") do |*args, block|
|
15
|
+
set_callback(:restore, :around, *args, block)
|
16
16
|
end
|
17
17
|
|
18
|
-
define_singleton_method("after_restore") do |*args,
|
19
|
-
set_callback(:restore, :after, *args,
|
18
|
+
define_singleton_method("after_restore") do |*args, block|
|
19
|
+
set_callback(:restore, :after, *args, block)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -54,7 +54,7 @@ module RailsSoftDeletable
|
|
54
54
|
# update_column(soft_deletable_column, 0)
|
55
55
|
|
56
56
|
name = soft_deletable_column.to_s
|
57
|
-
updated_count = self.class.unscoped.where(self.class.primary_key => id).update_all(name => 0
|
57
|
+
updated_count = self.class.unscoped.where(self.class.primary_key => id).update_all(name => 0)
|
58
58
|
raw_write_attribute(name, 0)
|
59
59
|
|
60
60
|
updated_count == 1
|
@@ -10,7 +10,9 @@ module RailsSoftDeletable
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def with_deleted
|
13
|
-
if ::ActiveRecord::VERSION::STRING >= "4.
|
13
|
+
if ::ActiveRecord::VERSION::STRING >= "4.1"
|
14
|
+
self.unscope(where: soft_deletable_column).all
|
15
|
+
elsif ::ActiveRecord::VERSION::STRING >= "4.0"
|
14
16
|
all.tap { |x| x.default_scoped = false }
|
15
17
|
else
|
16
18
|
scoped.tap { |x| x.default_scoped = false }
|
@@ -23,7 +23,7 @@ module RailsSoftDeletable
|
|
23
23
|
class_attribute :soft_deletable_column
|
24
24
|
|
25
25
|
self.soft_deletable_column = options[:column] || :deleted_at
|
26
|
-
default_scope { where(
|
26
|
+
default_scope { where(soft_deletable_column => 0) }
|
27
27
|
end
|
28
28
|
|
29
29
|
def soft_deletable?
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
File without changes
|