delete_paranoid 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use @delete_paranoid --create
@@ -3,12 +3,12 @@ require 'active_record'
3
3
 
4
4
  module ActiveRecord
5
5
  class Relation
6
- alias_method :delete_all!, :delete_all
6
+ alias_method :delete_all_permanently, :delete_all
7
7
  def delete_all(conditions = nil)
8
8
  if @klass.paranoid?
9
9
  update_all({:deleted_at => Time.now.utc}, conditions)
10
10
  else
11
- delete_all!(conditions)
11
+ delete_all_permanently(conditions)
12
12
  end
13
13
  end
14
14
  end
@@ -17,7 +17,7 @@ end
17
17
  module DeleteParanoid
18
18
  module ActiveRecordExtensions
19
19
  def acts_as_paranoid
20
- default_scope where(:deleted_at => nil)
20
+ default_scope { where(:deleted_at => nil) }
21
21
 
22
22
  extend DeleteParanoid::ClassMethods
23
23
  include DeleteParanoid::InstanceMethods
@@ -29,9 +29,9 @@ module DeleteParanoid
29
29
  end
30
30
 
31
31
  module ClassMethods
32
- # permenantly delete the record from the database
33
- def delete!(id_or_array)
34
- where(self.primary_key => id_or_array).delete_all!
32
+ # permanently delete the record from the database
33
+ def delete_permanently(id_or_array)
34
+ where(self.primary_key => id_or_array).delete_all_permanently
35
35
  end
36
36
  # allow for queries within block to find soft deleted records
37
37
  def with_deleted
@@ -45,19 +45,19 @@ module DeleteParanoid
45
45
  end
46
46
 
47
47
  module InstanceMethods
48
- # permenantly delete this specific instance from the database
49
- def destroy!
48
+ # permanently delete this specific instance from the database
49
+ def destroy_permanently
50
50
  result = destroy
51
51
  self.class.with_deleted do
52
- self.class.delete! self.id
52
+ self.class.delete_permanently self.id
53
53
  end
54
54
  result
55
55
  end
56
56
  # permenantly delete this specific instance from the database
57
- def delete!
57
+ def delete_permanently
58
58
  result = delete
59
59
  self.class.with_deleted do
60
- self.class.delete! self.id
60
+ self.class.delete_permanently self.id
61
61
  end
62
62
  result
63
63
  end
@@ -1,3 +1,3 @@
1
1
  module DeleteParanoid
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'helper')
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'helper.rb')
2
2
 
3
3
  class TestDeleteParanoid < Test::Unit::TestCase
4
4
  context 'with non-paranoid activerecord class' do
@@ -22,7 +22,6 @@ class TestDeleteParanoid < Test::Unit::TestCase
22
22
  @blog.destroy
23
23
  @blog
24
24
  end
25
-
26
25
  should destroy_subject.softly.and_freeze.and_mark_as_destroyed
27
26
  should trigger_callbacks_for :destroy
28
27
  should_not trigger_callbacks_for :update
@@ -34,32 +33,32 @@ class TestDeleteParanoid < Test::Unit::TestCase
34
33
  end
35
34
  should destroy_subject.softly
36
35
  end
37
- context "when destroying instance with Class.delete_all!" do
36
+ context "when destroying instance with Class.delete_all_permanently" do
38
37
  subject do
39
- Blog.where({:id => @blog.id}).delete_all!
38
+ Blog.where({:id => @blog.id}).delete_all_permanently
40
39
  @blog
41
40
  end
42
41
  should destroy_subject
43
42
  end
44
- context "when destroying instance with Class.delete!" do
43
+ context "when destroying instance with Class.delete_permanently" do
45
44
  subject do
46
- Blog.delete! @blog.id
45
+ Blog.delete_permanently @blog.id
47
46
  @blog
48
47
  end
49
48
  should destroy_subject
50
49
  end
51
- context 'when destroying instance with instance.destroy!' do
50
+ context 'when destroying instance with instance.destroy_permanently' do
52
51
  subject do
53
- @blog.destroy!
52
+ @blog.destroy_permanently
54
53
  @blog
55
54
  end
56
55
  should destroy_subject
57
56
  should trigger_callbacks_for :destroy
58
57
  should_not trigger_callbacks_for :update
59
58
  end
60
- context 'when destroying instance with instance.delete!' do
59
+ context 'when destroying instance with instance.delete_permanently' do
61
60
  subject do
62
- @blog.delete!
61
+ @blog.delete_permanently
63
62
  @blog
64
63
  end
65
64
  should destroy_subject
@@ -81,9 +80,9 @@ class TestDeleteParanoid < Test::Unit::TestCase
81
80
  should trigger_callbacks_for :destroy
82
81
  #should_not trigger_callbacks_for :update
83
82
  end
84
- context 'when destroying parent paranoid instance with delete_all!' do
83
+ context 'when destroying parent paranoid instance with delete_all_permanently' do
85
84
  subject do
86
- Blog.where({:id => @blog.id}).delete_all!
85
+ Blog.where({:id => @blog.id}).delete_all_permanently
87
86
  @comment
88
87
  end
89
88
 
@@ -106,9 +105,9 @@ class TestDeleteParanoid < Test::Unit::TestCase
106
105
  should trigger_callbacks_for :destroy
107
106
  #should_not trigger_callbacks_for :update
108
107
  end
109
- context 'when destroying parent paranoid instance with delete_all!' do
108
+ context 'when destroying parent paranoid instance with delete_all_permanently' do
110
109
  subject do
111
- Blog.where({:id => @blog.id}).delete_all!
110
+ Blog.where({:id => @blog.id}).delete_all_permanently
112
111
  @link
113
112
  end
114
113
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delete_paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-24 00:00:00.000000000 Z
12
+ date: 2013-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &2152368180 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152368180
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: shoulda
27
- requirement: &2152367060 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *2152367060
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: mocha
38
- requirement: &2152364200 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *2152364200
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: bundler
49
- requirement: &2152362780 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *2152362780
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: sqlite3-ruby
60
- requirement: &2152359780 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: 1.3.2
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *2152359780
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.2
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: timecop
71
- requirement: &2152358320 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *2152358320
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: rake
82
- requirement: &2152357260 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,7 +117,12 @@ dependencies:
87
117
  version: 0.9.2.2
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *2152357260
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 0.9.2.2
91
126
  description: flag database records as deleted and hide them from subsequent queries
92
127
  email:
93
128
  - ryan@codecrate.com
@@ -96,6 +131,7 @@ extensions: []
96
131
  extra_rdoc_files: []
97
132
  files:
98
133
  - .gitignore
134
+ - .rvmrc
99
135
  - .travis.yml
100
136
  - CONTRIBUTORS.txt
101
137
  - Gemfile
@@ -123,15 +159,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
159
  - - ! '>='
124
160
  - !ruby/object:Gem::Version
125
161
  version: '0'
162
+ segments:
163
+ - 0
164
+ hash: -2970473381417290609
126
165
  required_rubygems_version: !ruby/object:Gem::Requirement
127
166
  none: false
128
167
  requirements:
129
168
  - - ! '>='
130
169
  - !ruby/object:Gem::Version
131
170
  version: '0'
171
+ segments:
172
+ - 0
173
+ hash: -2970473381417290609
132
174
  requirements: []
133
175
  rubyforge_project: delete_paranoid
134
- rubygems_version: 1.8.10
176
+ rubygems_version: 1.8.24
135
177
  signing_key:
136
178
  specification_version: 3
137
179
  summary: soft delete Rails ActiveRecord objects