pub_sub_model_sync 0.5.9 → 0.5.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/pub_sub_model_sync/message_publisher.rb +1 -1
- data/lib/pub_sub_model_sync/payload.rb +3 -1
- data/lib/pub_sub_model_sync/publisher.rb +3 -3
- data/lib/pub_sub_model_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 585431eec8ef5f6f9d4b0ccea9069d03ea2849d94f7a8f43464f588da8cfae6c
|
4
|
+
data.tar.gz: 4ebf42b8ca72c0bf150f3c27a9ca9b791532954deb1663c571927324be952589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f0c786ff6de119c0add336c0182158f4c5ab3b9b74d2f9e3f180b3753ac288ecc8e2c6c88149ad82a627691c924f049eeb5e02c39280ec7ce3d04831b99dd18
|
7
|
+
data.tar.gz: f7ae9286d95af747dd8bd5e21c5f4f87e8aec469077663782103738f7ae9d07fa39b4884f5741e572f17b57a1ce6c358fe8ded7334451aa703559b7367218653
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
# 0.5.9.1 (February 10, 2021)
|
4
|
+
- feat: move :key into headers
|
5
|
+
|
3
6
|
# 0.5.9 (February 10, 2021)
|
4
7
|
- feat: reformat :publish and :process methods to include non silence methods
|
5
8
|
- feat: add notification key to payloads (can be used for caching strategies)
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ module PubSubModelSync
|
|
12
12
|
# @param data (Hash): Data to be delivered
|
13
13
|
# @param action (:symbol): action name
|
14
14
|
def publish_data(klass, data, action)
|
15
|
-
attrs = { klass: klass.to_s, action: action.to_sym
|
15
|
+
attrs = { klass: klass.to_s, action: action.to_sym }
|
16
16
|
payload = PubSubModelSync::Payload.new(data, attrs)
|
17
17
|
publish(payload)
|
18
18
|
end
|
@@ -6,7 +6,8 @@ module PubSubModelSync
|
|
6
6
|
attr_reader :data, :attributes, :headers
|
7
7
|
|
8
8
|
# @param data (Hash: { any value }):
|
9
|
-
# @param attributes (Hash: { klass*: string, action*: :sym
|
9
|
+
# @param attributes (Hash: { klass*: string, action*: :sym }):
|
10
|
+
# @param headers (Hash: { key?: string, ...any_key?: anything }):
|
10
11
|
def initialize(data, attributes, headers = {})
|
11
12
|
@data = data
|
12
13
|
@attributes = attributes
|
@@ -68,6 +69,7 @@ module PubSubModelSync
|
|
68
69
|
def build_headers
|
69
70
|
headers[:uuid] ||= SecureRandom.uuid
|
70
71
|
headers[:app_key] ||= PubSubModelSync::Config.subscription_key
|
72
|
+
headers[:key] ||= [klass.to_s, action].join('/')
|
71
73
|
end
|
72
74
|
|
73
75
|
def validate!
|
@@ -13,7 +13,8 @@ module PubSubModelSync
|
|
13
13
|
|
14
14
|
# Builds the payload with model information defined for :action (:create|:update|:destroy)
|
15
15
|
def payload(model, action)
|
16
|
-
|
16
|
+
headers = { key: [model.class.name, action, model.id].join('/') }
|
17
|
+
PubSubModelSync::Payload.new(payload_data(model), payload_attrs(model, action), headers)
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
@@ -32,8 +33,7 @@ module PubSubModelSync
|
|
32
33
|
def payload_attrs(model, action)
|
33
34
|
{
|
34
35
|
klass: (as_klass || model.class.name).to_s,
|
35
|
-
action: action.to_sym
|
36
|
-
key: [model.class.name, action, model.id].join('/')
|
36
|
+
action: action.to_sym
|
37
37
|
}
|
38
38
|
end
|
39
39
|
end
|