sidekiq-serialized_current_attributes 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07c37997ce8b0667f2dd9e99986564a2ba5dd34a921d6d1675ee1828266e042e
|
4
|
+
data.tar.gz: c05a2b825b218f49bc20959335daca3b6c4579521aedeb7f58a818897e9b3c2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 963c511d092b8a63bf02cdc8acc760544925d0eabde637e55fc0ebe31f2b2ca524c90c768a73cc32b977c2d3549423a00ae745d0e953399fee3bb44889de145a
|
7
|
+
data.tar.gz: 8ceded7169036323ab85b47f1c6a025f73fefb2e1d5c10f9540e717e8c1e98c3eafcc903cdc8f360dbcf61dffb9b09d2e744e1d3b78fef05d6efea085d9498bc
|
data/README.md
CHANGED
@@ -22,8 +22,21 @@ require "sidekiq/serialized_current_attributes"
|
|
22
22
|
Sidekiq::SerializedCurrentAttributes.persist("Myapp::Current")
|
23
23
|
# or multiple current attributes
|
24
24
|
Sidekiq::SerializedCurrentAttributes.persist(["Myapp::Current", "Myapp::OtherCurrent"])
|
25
|
+
|
26
|
+
# Discard destroyed records when serializing Current
|
27
|
+
Sidekiq::SerializedCurrentAttributes.discard_destroyed = true
|
25
28
|
```
|
26
29
|
|
30
|
+
## Changelog
|
31
|
+
|
32
|
+
### 0.1.1 (2023-10-16)
|
33
|
+
|
34
|
+
- Add option to discard destroyed records
|
35
|
+
|
36
|
+
### 0.1.0
|
37
|
+
|
38
|
+
- Initial release
|
39
|
+
|
27
40
|
## License
|
28
41
|
|
29
42
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -3,12 +3,15 @@
|
|
3
3
|
require "sidekiq"
|
4
4
|
require "active_support/current_attributes"
|
5
5
|
require "active_job/arguments"
|
6
|
+
require "active_support/core_ext/module/attribute_accessors"
|
6
7
|
|
7
8
|
require_relative "serialized_current_attributes/version"
|
8
9
|
|
9
10
|
# Code is pretty directly taken from https://github.com/sidekiq/sidekiq/blob/main/lib/sidekiq/middleware/current_attributes.rb, and adjusted so it uses ActiveJob argument serialization to support storing models.
|
10
11
|
module Sidekiq
|
11
12
|
module SerializedCurrentAttributes
|
13
|
+
mattr_accessor :discard_destroyed, default: false
|
14
|
+
|
12
15
|
class Save
|
13
16
|
include Sidekiq::ClientMiddleware
|
14
17
|
|
@@ -29,6 +32,10 @@ module Sidekiq
|
|
29
32
|
end
|
30
33
|
|
31
34
|
def serialize(attributes)
|
35
|
+
if Sidekiq::SerializedCurrentAttributes.discard_destroyed
|
36
|
+
attributes = attributes.reject { |_, value| value.is_a?(GlobalID::Identification) && value.respond_to?(:destroyed?) && value.destroyed? }
|
37
|
+
end
|
38
|
+
|
32
39
|
serialized_values = ActiveJob::Arguments.serialize(attributes.values)
|
33
40
|
attributes.keys.zip(serialized_values).to_h
|
34
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-serialized_current_attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabian Schwahn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|