soft_deletion 0.1.7 → 0.1.8
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.
- data/Gemfile.lock +1 -1
- data/gemfiles/rails2.gemfile.lock +1 -1
- data/gemfiles/rails3.gemfile.lock +1 -1
- data/lib/soft_deletion/version.rb +1 -1
- data/lib/soft_deletion.rb +10 -9
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/soft_deletion.rb
CHANGED
@@ -8,7 +8,16 @@ module SoftDeletion
|
|
8
8
|
raise "You can only include this if #{base} extends ActiveRecord::Base"
|
9
9
|
end
|
10
10
|
base.extend(ClassMethods)
|
11
|
-
|
11
|
+
|
12
|
+
if base.respond_to?(:define_default_soft_delete_scope)
|
13
|
+
base.define_default_soft_delete_scope
|
14
|
+
else
|
15
|
+
# Avoids a bad SQL request with versions of code without the column deleted_at (for example a migration prior to the migration
|
16
|
+
# that adds deleted_at)
|
17
|
+
if base.column_names.include?('deleted_at')
|
18
|
+
base.send(:default_scope, :conditions => { :deleted_at => nil })
|
19
|
+
end
|
20
|
+
end
|
12
21
|
|
13
22
|
# backport after_soft_delete so we can safely upgrade to rails 3
|
14
23
|
if ActiveRecord::VERSION::MAJOR > 2
|
@@ -29,14 +38,6 @@ module SoftDeletion
|
|
29
38
|
end
|
30
39
|
|
31
40
|
module ClassMethods
|
32
|
-
def define_default_soft_delete_scope
|
33
|
-
# Avoids a bad SQL request with versions of code without the column deleted_at (for example a migration prior to the migration
|
34
|
-
# that adds deleted_at)
|
35
|
-
if column_names.include?('deleted_at')
|
36
|
-
default_scope :conditions => { :deleted_at => nil }
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
41
|
def soft_delete_dependents
|
41
42
|
self.reflect_on_all_associations.
|
42
43
|
select { |a| [:destroy, :delete_all, :nullify].include?(a.options[:dependent]) }.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soft_deletion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zendesk
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-06-
|
18
|
+
date: 2012-06-28 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description:
|