soft_delete-workbar 0.1.1 → 1.0.0
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.
- checksums.yaml +4 -4
- data/README.md +46 -5
- data/lib/soft_delete.rb +3 -1
- data/lib/soft_delete/version.rb +1 -1
- metadata +49 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b49b2b95fd1db7c571e14ac0b93d338a0a557ae4
|
4
|
+
data.tar.gz: 1fe9ff3aa76631fb6a23305d32dc84073bf33d3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa0698e1524f2e7b03f13f8ea1c052afac3b81b43004576d545098f583f1b98cab16be19a9246c2ebcf249f249769bbe5aa08edf6eb0b9b5ca1cac447218b82
|
7
|
+
data.tar.gz: 34f45645f3b5bfe979accdcea46764a6e0e95a8e547e59c26a2f83317a93719cbc3c909c0536f02f069fee61cc251076ebf19b6aeb00e93a8627306f08deae5f
|
data/README.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# Soft Delete
|
2
|
+
|
3
|
+
> In a production app, you should probably never really delete anything.
|
4
|
+
|
5
|
+
[source](https://twitter.com/theebeastmaster/status/966870021099180034)
|
6
|
+
|
7
|
+
A soft-delete marks a record as deleted, and keeps it in the database
|
8
|
+
for historical reference.
|
9
|
+
|
1
10
|
## Installation
|
2
11
|
|
3
12
|
Add this line to your application's Gemfile:
|
@@ -20,7 +29,7 @@ Safely "delete" records from your database without losing them permanently.
|
|
20
29
|
|
21
30
|
* Add SoftDelete to a model
|
22
31
|
```
|
23
|
-
class MyModel
|
32
|
+
class MyModel < ActiveRecord::Base
|
24
33
|
include SoftDelete
|
25
34
|
end
|
26
35
|
```
|
@@ -30,16 +39,48 @@ Safely "delete" records from your database without losing them permanently.
|
|
30
39
|
```
|
31
40
|
* Safely call `MyModel#delete` without losing the record forever
|
32
41
|
|
42
|
+
## Methods
|
43
|
+
|
44
|
+
Please see the `SoftDelete` module and the associated tests for a description of
|
45
|
+
the methods that will be added to your model.
|
46
|
+
|
47
|
+
* `.not_deleted` - records without a deleted_at timestamp
|
48
|
+
* `.deleted` - records with a deleted_at timestamp
|
49
|
+
* `#delete` - set the deleted_at timestamp
|
50
|
+
* `#delete!` - delete the record from the database
|
51
|
+
* `#destroy` - set the deleted_at timestamp, and run callbacks
|
52
|
+
* `#destroy!` - delete the record from the database, and run callbacks
|
53
|
+
* `#restore` - set the deleted_at timestamp to nil
|
54
|
+
|
55
|
+
It will be necessary to exclude deleted records when querying the model.
|
56
|
+
Use the `not_deleted` scope that now exists on the model.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
class MyModelsController < ApplicationController
|
60
|
+
def index
|
61
|
+
@my_models = MyModel.not_deleted
|
62
|
+
end
|
63
|
+
end
|
64
|
+
```
|
65
|
+
|
33
66
|
## Development
|
34
67
|
|
35
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
68
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
69
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
70
|
+
prompt that will allow you to experiment.
|
36
71
|
|
37
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
72
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
73
|
+
release a new version, update the version number in `version.rb`, and then run
|
74
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
75
|
+
git commits and tags, and push the `.gem` file to
|
76
|
+
[rubygems.org](https://rubygems.org).
|
38
77
|
|
39
78
|
## Contributing
|
40
79
|
|
41
|
-
Bug reports and pull requests are welcome on GitHub at
|
80
|
+
Bug reports and pull requests are welcome on GitHub at
|
81
|
+
https://github.com/workbar-dev/soft_delete.
|
42
82
|
|
43
83
|
## License
|
44
84
|
|
45
|
-
The gem is available as open source under the terms of the
|
85
|
+
The gem is available as open source under the terms of the
|
86
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
data/lib/soft_delete.rb
CHANGED
data/lib/soft_delete/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soft_delete-workbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Davis
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-02-
|
12
|
+
date: 2018-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -102,6 +102,15 @@ dependencies:
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '4.0'
|
104
104
|
description: |
|
105
|
+
# Soft Delete
|
106
|
+
|
107
|
+
> In a production app, you should probably never really delete anything.
|
108
|
+
|
109
|
+
[source](https://twitter.com/theebeastmaster/status/966870021099180034)
|
110
|
+
|
111
|
+
A soft-delete marks a record as deleted, and keeps it in the database
|
112
|
+
for historical reference.
|
113
|
+
|
105
114
|
## Installation
|
106
115
|
|
107
116
|
Add this line to your application's Gemfile:
|
@@ -124,7 +133,7 @@ description: |
|
|
124
133
|
|
125
134
|
* Add SoftDelete to a model
|
126
135
|
```
|
127
|
-
class MyModel
|
136
|
+
class MyModel < ActiveRecord::Base
|
128
137
|
include SoftDelete
|
129
138
|
end
|
130
139
|
```
|
@@ -134,19 +143,51 @@ description: |
|
|
134
143
|
```
|
135
144
|
* Safely call `MyModel#delete` without losing the record forever
|
136
145
|
|
146
|
+
## Methods
|
147
|
+
|
148
|
+
Please see the `SoftDelete` module and the associated tests for a description of
|
149
|
+
the methods that will be added to your model.
|
150
|
+
|
151
|
+
* `.not_deleted` - records without a deleted_at timestamp
|
152
|
+
* `.deleted` - records with a deleted_at timestamp
|
153
|
+
* `#delete` - set the deleted_at timestamp
|
154
|
+
* `#delete!` - delete the record from the database
|
155
|
+
* `#destroy` - set the deleted_at timestamp, and run callbacks
|
156
|
+
* `#destroy!` - delete the record from the database, and run callbacks
|
157
|
+
* `#restore` - set the deleted_at timestamp to nil
|
158
|
+
|
159
|
+
It will be necessary to exclude deleted records when querying the model.
|
160
|
+
Use the `not_deleted` scope that now exists on the model.
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
class MyModelsController < ApplicationController
|
164
|
+
def index
|
165
|
+
@my_models = MyModel.not_deleted
|
166
|
+
end
|
167
|
+
end
|
168
|
+
```
|
169
|
+
|
137
170
|
## Development
|
138
171
|
|
139
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
172
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
173
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
174
|
+
prompt that will allow you to experiment.
|
140
175
|
|
141
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To
|
176
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
177
|
+
release a new version, update the version number in `version.rb`, and then run
|
178
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
179
|
+
git commits and tags, and push the `.gem` file to
|
180
|
+
[rubygems.org](https://rubygems.org).
|
142
181
|
|
143
182
|
## Contributing
|
144
183
|
|
145
|
-
Bug reports and pull requests are welcome on GitHub at
|
184
|
+
Bug reports and pull requests are welcome on GitHub at
|
185
|
+
https://github.com/workbar-dev/soft_delete.
|
146
186
|
|
147
187
|
## License
|
148
188
|
|
149
|
-
The gem is available as open source under the terms of the
|
189
|
+
The gem is available as open source under the terms of the
|
190
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
150
191
|
email:
|
151
192
|
- riki@workbar.com
|
152
193
|
executables: []
|
@@ -185,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
226
|
version: '0'
|
186
227
|
requirements: []
|
187
228
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
229
|
+
rubygems_version: 2.5.2.1
|
189
230
|
signing_key:
|
190
231
|
specification_version: 4
|
191
232
|
summary: A no-frills implementation of soft delete for Rails
|