activerecord-prunable 0.3.0 → 0.3.1
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/Gemfile.lock +1 -1
- data/README.md +4 -3
- data/activerecord-prunable.gemspec +1 -1
- data/lib/activerecord-prunable.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee37713079a5a97f560f7a5f7097b7964e0972e6
|
4
|
+
data.tar.gz: d10414c12f3c76966518574dca18cef65e9da778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa8cb1090569daf9961710a42706630cf900c16984ab1532d27be70dc32bfbb355e05875bf5ada1b7c2f328c8561d8659cfe5fc0030c719f7c9b92ce8a5edc2
|
7
|
+
data.tar.gz: 16b036c67c94558129661f2282e476eb64f21ff0d731dc033e4eeebd1622d25bd07e9dcaff1902ce1b0cbda1895642253b33d90d9c4e5dddf06e6b4202799b07
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,8 +21,9 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
__1. Include the `Prunable` module in the ActiveRecord model which needs to be pruned.__
|
25
|
+
|
26
|
+
__2. Define the `:prunable` scope which returns models to prune.__
|
26
27
|
|
27
28
|
```ruby
|
28
29
|
class Notification < ApplicationRecord
|
@@ -50,7 +51,7 @@ Or install it yourself as:
|
|
50
51
|
`prune_created_after(TTL)` defines `where('created_at < ?', current_time - TTL)` prunable scope
|
51
52
|
`prune_updated_after(TTL)` defines `where('updated_at < ?', current_time - TTL)` prunable scope
|
52
53
|
|
53
|
-
|
54
|
+
__3. Add a `Prunable.prune!` call to a periodic task.__
|
54
55
|
|
55
56
|
Example:
|
56
57
|
|
@@ -11,11 +11,11 @@ module Prunable
|
|
11
11
|
ActiveRecord::Prunable.includes
|
12
12
|
end
|
13
13
|
|
14
|
-
def prune!(*models, prune_method: nil, params: [])
|
14
|
+
def prune!(*models, prune_method: nil, current_time: nil, params: [])
|
15
15
|
models = self.models if models.empty?
|
16
16
|
|
17
17
|
models.each do |model|
|
18
|
-
model.prune!(*params, prune_method: prune_method)
|
18
|
+
model.prune!(*params, prune_method: prune_method, current_time: current_time)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-prunable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dr2m
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|