activerecord-prunable 0.4.3 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8dd903bc39672f786b325d8907bfba3b4ba1d47e
4
- data.tar.gz: 6377d77ab1c31b4d8ee4c38cd104c8e091df35a9
3
+ metadata.gz: d40d467ab85540ecaf695bab2974816e41161e09
4
+ data.tar.gz: 70488ff303ea76a6bfc5c997523c76fef3d33a3c
5
5
  SHA512:
6
- metadata.gz: 502ae14d858b2b7f0997b70e1a752d165a1e553d511772a3412cbece5ce18b0b2becbc40e0a44238e6955241fa85ca5c19527da7ba12270d355ee5be245d194f
7
- data.tar.gz: 5776ff5903da67cbf0b55c2b36f6c5b4c8605e9aa5ba6570e5160541bb2322ea7d2487fb79650a4d0d006e9a36a53d3645efc826f97a0c88e00402a859a1ba70
6
+ metadata.gz: d4cddff27a65443463d0f8e0d7ed0ee089e3dfa7b6e0903fe894a15d1a6155593760451ef48c03cab8a233b78ba4ba062d118c9373194d444160a846bdfb2a17
7
+ data.tar.gz: 51e402061a8349eeb1206931b5bb309e8c1959bdd8081d52da730d14312ff1242a63a5c5d69ee4ab2ed1aba3629552f5abb9092328a93c3c0c5d43e7bef09407
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activerecord-prunable (0.4.2)
4
+ activerecord-prunable (0.4.3)
5
5
  activerecord (>= 3.0, < 6.0)
6
6
  activesupport (>= 3.0, < 6.0)
7
7
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "activerecord-prunable"
3
- spec.version = "0.4.3"
3
+ spec.version = "0.4.4"
4
4
  spec.authors = ["dr2m"]
5
5
  spec.email = ["maletin@maletin.work"]
6
6
 
@@ -30,14 +30,20 @@ module ActiveRecord
30
30
  class_variable_set(:@@prune_method, method)
31
31
  end
32
32
 
33
- def prune_created_after(duration)
33
+ def prune_created_after(duration, batch_removal: nil, remove_in_batches: nil)
34
34
  class_variable_set(:@@prune_created_after, duration)
35
+
36
+ batch_removal_arg = batch_removal || remove_in_batches
37
+ batch_removal(batch_removal_arg) if batch_removal_arg
35
38
  end
36
39
 
37
40
  alias prune_after prune_created_after
38
41
 
39
- def prune_updated_after(duration)
42
+ def prune_updated_after(duration, batch_removal: nil, remove_in_batches: nil)
40
43
  class_variable_set(:@@prune_updated_after, duration)
44
+
45
+ batch_removal_arg = batch_removal || remove_in_batches
46
+ batch_removal(batch_removal_arg) if batch_removal_arg
41
47
  end
42
48
 
43
49
  def prune!(*params, prune_method: nil, current_time: nil, batch_size: nil, in_batches: false)
@@ -58,9 +64,11 @@ module ActiveRecord
58
64
  destroyed_records
59
65
  end
60
66
 
61
- def batch_removal(batch_size = 1000)
67
+ def batch_removal(batch_size = nil)
68
+ batch_size = 1000 unless batch_size.is_a?(Integer)
62
69
  class_variable_set(:@@prunable_batch_size, batch_size)
63
70
  end
71
+ alias remove_in_batches batch_removal
64
72
 
65
73
  private
66
74
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-prunable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - dr2m