never_wastes 0.0.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in never_wastes.gemspec
4
4
  gemspec
5
+
6
+ # gem 'rails', '3.2.15'
data/README.md CHANGED
@@ -67,14 +67,18 @@ Then you can use destroy for soft delete.
67
67
 
68
68
  model.destroy
69
69
 
70
- If you want hard delete, use destroy!.
70
+ If you want hard delete, use demolish.
71
71
 
72
- model.destroy!
72
+ model.demolish
73
+
74
+ Using Rails 4.0 or later, you can use #demolish! instead of #destroy!.
73
75
 
74
76
  You can get non-deleted models by default.
75
77
 
76
78
  models = YourModel.all # deleted models are not included
77
79
 
80
+ This gem also changes .delete_all to soft deletion. You can use .demolish_all as the original .delete_all.
81
+
78
82
  If you need to get models with deleted ones, you can use with_deleted.
79
83
 
80
84
  models = YourModel.with_deleted.all
@@ -28,7 +28,8 @@ module NeverWastes
28
28
  self.never_wastes_datetime_column_name = :deleted_at
29
29
  self.never_wastes_id_column_name = :waste_id
30
30
 
31
- alias_method :destroy!, :destroy
31
+ alias_method :demolish, :destroy
32
+ alias_method :demolish!, :destroy! if instance_methods.include?(:destroy!)
32
33
 
33
34
  def destroy_softly
34
35
  @destroying_softly = true
@@ -53,7 +54,8 @@ module NeverWastes
53
54
  unscoped
54
55
  end
55
56
 
56
- alias_method :delete_all!, :delete_all
57
+ alias_method :demolish_all, :delete_all
58
+
57
59
  def delete_all_softly
58
60
  updates = sanitize_sql_for_assignment(never_wastes_boolean_column_name => true)
59
61
  if column_names.include?(never_wastes_datetime_column_name.to_s)
@@ -1,3 +1,3 @@
1
1
  module NeverWastes
2
- VERSION = "0.0.8"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -113,15 +113,15 @@ describe User do
113
113
  end
114
114
  end
115
115
 
116
- describe ".delete_all!" do
116
+ describe ".demolish_all" do
117
117
  let!(:delete_users) { (1..3).inject([]) { |result, i| result << Factory.create(:user, deleted: false, deleted_at: nil) } }
118
118
  let!(:undelete_user) { Factory.create(:user, name: 'undeleted', deleted: false, deleted_at: nil) }
119
119
  it "should be successful" do
120
- expect { User.where(User.arel_table[:name].not_eq('undeleted')).delete_all! }.to change(User, :count).by(-3)
120
+ expect { User.where(User.arel_table[:name].not_eq('undeleted')).demolish_all }.to change(User, :count).by(-3)
121
121
  end
122
122
 
123
123
  it "should delete users" do
124
- expect { User.where(User.arel_table[:name].not_eq('undeleted')).delete_all! }.to change(User.unscoped, :count).by(-3)
124
+ expect { User.where(User.arel_table[:name].not_eq('undeleted')).demolish_all }.to change(User.unscoped, :count).by(-3)
125
125
  end
126
126
  end
127
127
  end
metadata CHANGED
@@ -1,88 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: never_wastes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 1.0.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - nay3
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-10-25 00:00:00.000000000 Z
12
+ date: 2013-12-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 3.0.0
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 3.0.0
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: activerecord
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: 3.0.0
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: 3.0.0
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: bundler
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: 1.0.0
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: 1.0.0
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: sqlite3
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: '0'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - '>='
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: rspec
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - '>='
83
+ - - ! '>='
74
84
  - !ruby/object:Gem::Version
75
85
  version: '0'
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - '>='
91
+ - - ! '>='
81
92
  - !ruby/object:Gem::Version
82
93
  version: '0'
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: factory_girl
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
99
  - - <
88
100
  - !ruby/object:Gem::Version
@@ -90,6 +102,7 @@ dependencies:
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
107
  - - <
95
108
  - !ruby/object:Gem::Version
@@ -97,15 +110,17 @@ dependencies:
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: database_cleaner
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
- - - '>='
115
+ - - ! '>='
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
- - - '>='
123
+ - - ! '>='
109
124
  - !ruby/object:Gem::Version
110
125
  version: '0'
111
126
  description: It changes ActiveRecord::Base#destroy to support soft delete. Kind of
@@ -131,29 +146,31 @@ files:
131
146
  - spec/support/database_cleaner.rb
132
147
  homepage: ''
133
148
  licenses: []
134
- metadata: {}
135
149
  post_install_message:
136
150
  rdoc_options: []
137
151
  require_paths:
138
152
  - lib
139
153
  required_ruby_version: !ruby/object:Gem::Requirement
154
+ none: false
140
155
  requirements:
141
- - - '>='
156
+ - - ! '>='
142
157
  - !ruby/object:Gem::Version
143
158
  version: '0'
144
159
  required_rubygems_version: !ruby/object:Gem::Requirement
160
+ none: false
145
161
  requirements:
146
- - - '>='
162
+ - - ! '>='
147
163
  - !ruby/object:Gem::Version
148
164
  version: '0'
149
165
  requirements: []
150
166
  rubyforge_project: never_wastes
151
- rubygems_version: 2.0.4
167
+ rubygems_version: 1.8.24
152
168
  signing_key:
153
- specification_version: 4
169
+ specification_version: 3
154
170
  summary: simple soft delete for ActiveRecord
155
171
  test_files:
156
172
  - spec/fake_app.rb
157
173
  - spec/never_wastes_spec.rb
158
174
  - spec/spec_helper.rb
159
175
  - spec/support/database_cleaner.rb
176
+ has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: c85ab18840099a907e37896a9fbdf155c84720fb
4
- data.tar.gz: 9bfc863a688d3193001729ec8f7a3935cd27172f
5
- SHA512:
6
- metadata.gz: 654a6ce77cf9a29bff70389bc8acc7f862a340cc575573cae72b4294513686d3af5f6a512a5d5fdf27e5447c7c304a229c67c70019624a3c4ca37275b5741c02
7
- data.tar.gz: 738da964f16210ba589c578e99d5ffa0f06de65a5a68191fe548e589adb9c721687c82fd3844ffcdbd0cb67b6f4d72e8f328a6612daa62b8246be60d03600573