soft_deletion 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/Readme.md +5 -0
- data/gemfiles/rails2.gemfile.lock +1 -1
- data/gemfiles/rails3.gemfile.lock +1 -1
- data/lib/soft_deletion.rb +2 -2
- data/lib/soft_deletion/version.rb +1 -1
- data/test/soft_deletion_test.rb +8 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -14,6 +14,10 @@ Usage
|
|
14
14
|
# mix into any model ...
|
15
15
|
class User < ActiveRecord::Base
|
16
16
|
include SoftDeletion
|
17
|
+
|
18
|
+
after_soft_delete :send_deletion_emails # Rails 2 + 3
|
19
|
+
set_callback :soft_delete, :after, :prepare_emails # Rails 3
|
20
|
+
|
17
21
|
has_many :products
|
18
22
|
end
|
19
23
|
|
@@ -34,6 +38,7 @@ Usage
|
|
34
38
|
user.soft_undelete!
|
35
39
|
user.products.count == 10
|
36
40
|
|
41
|
+
|
37
42
|
TODO
|
38
43
|
====
|
39
44
|
- Rails 3 from with inspiration from https://github.com/JackDanger/permanent_records/blob/master/lib/permanent_records.rb
|
data/lib/soft_deletion.rb
CHANGED
@@ -14,8 +14,8 @@ module SoftDeletion
|
|
14
14
|
if ActiveRecord::VERSION::MAJOR > 2
|
15
15
|
base.define_callbacks :soft_delete
|
16
16
|
class << base
|
17
|
-
def after_soft_delete(
|
18
|
-
set_callback :soft_delete, :after,
|
17
|
+
def after_soft_delete(*callbacks)
|
18
|
+
set_callback :soft_delete, :after, *callbacks
|
19
19
|
end
|
20
20
|
end
|
21
21
|
else
|
data/test/soft_deletion_test.rb
CHANGED
@@ -95,8 +95,15 @@ class SoftDeletionTest < ActiveSupport::TestCase
|
|
95
95
|
category.soft_delete!
|
96
96
|
end
|
97
97
|
|
98
|
+
should "be call multiple after soft-deletion" do
|
99
|
+
Category.after_soft_delete :foo, :bar
|
100
|
+
category = Category.create!
|
101
|
+
category.expects(:foo)
|
102
|
+
category.expects(:bar)
|
103
|
+
category.soft_delete!
|
104
|
+
end
|
105
|
+
|
98
106
|
should "not be called after normal destroy" do
|
99
|
-
# TODO clear all callbacks
|
100
107
|
Category.after_soft_delete :foo
|
101
108
|
category = Category.create!
|
102
109
|
category.expects(:foo).never
|
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: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
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-05-
|
18
|
+
date: 2012-05-03 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description:
|