pub_sub_model_sync 0.4.1 → 0.4.2
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/CHANGELOG.md +1 -1
- data/Gemfile.lock +8 -8
- data/README.md +8 -1
- data/lib/pub_sub_model_sync/publisher_concern.rb +1 -2
- data/lib/pub_sub_model_sync/subscriber.rb +1 -2
- data/lib/pub_sub_model_sync/subscriber_concern.rb +5 -0
- data/lib/pub_sub_model_sync/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0bd383488f8214ca409871adf231319b905f41833b8a9db9c2bc58a9d5a2691
|
4
|
+
data.tar.gz: c05ca888a6c085280407f9a1e26fe7552efa1c33f6be7735129ff2f8addd77fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8769aee9d08936fd9fd4707e1dd5664c30ccbb6b2b59e386182ac4a0c173b46813df9ca5ccc3a3e3139af4297c160ca5ddb05a555d8f2c1fbb719e7a54384f4
|
7
|
+
data.tar.gz: bc25309e3894fd5905d0e3fdc180d93a98cfced77ff006f24d0044f1db717f5b0fa475722126901ec18381d3e4890a2a0ff00f7ecb234405cdad4a1e7049a5fb
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pub_sub_model_sync (0.4.
|
4
|
+
pub_sub_model_sync (0.4.2)
|
5
5
|
rails
|
6
6
|
|
7
7
|
GEM
|
@@ -122,7 +122,7 @@ GEM
|
|
122
122
|
concurrent-ruby (~> 1.0)
|
123
123
|
jaro_winkler (1.5.4)
|
124
124
|
jwt (2.2.1)
|
125
|
-
loofah (2.
|
125
|
+
loofah (2.6.0)
|
126
126
|
crass (~> 1.0.2)
|
127
127
|
nokogiri (>= 1.5.9)
|
128
128
|
mail (2.7.1)
|
@@ -131,21 +131,21 @@ GEM
|
|
131
131
|
mimemagic (~> 0.3.2)
|
132
132
|
memoist (0.16.2)
|
133
133
|
method_source (1.0.0)
|
134
|
-
mimemagic (0.3.
|
134
|
+
mimemagic (0.3.5)
|
135
135
|
mini_mime (1.0.2)
|
136
136
|
mini_portile2 (2.4.0)
|
137
137
|
minitest (5.14.0)
|
138
138
|
multi_json (1.14.1)
|
139
139
|
multipart-post (2.1.1)
|
140
140
|
nio4r (2.5.2)
|
141
|
-
nokogiri (1.10.
|
141
|
+
nokogiri (1.10.10)
|
142
142
|
mini_portile2 (~> 2.4.0)
|
143
143
|
os (1.0.1)
|
144
144
|
parallel (1.19.1)
|
145
145
|
parser (2.7.0.4)
|
146
146
|
ast (~> 2.4.0)
|
147
147
|
public_suffix (4.0.3)
|
148
|
-
rack (2.2.
|
148
|
+
rack (2.2.3)
|
149
149
|
rack-test (1.1.0)
|
150
150
|
rack (>= 1.0, < 3)
|
151
151
|
rails (6.0.2.2)
|
@@ -207,7 +207,7 @@ GEM
|
|
207
207
|
faraday (~> 0.9)
|
208
208
|
jwt (>= 1.5, < 3.0)
|
209
209
|
multi_json (~> 1.10)
|
210
|
-
sprockets (4.0.
|
210
|
+
sprockets (4.0.2)
|
211
211
|
concurrent-ruby (~> 1.0)
|
212
212
|
rack (> 1, < 3)
|
213
213
|
sprockets-rails (3.2.1)
|
@@ -220,9 +220,9 @@ GEM
|
|
220
220
|
tzinfo (1.2.7)
|
221
221
|
thread_safe (~> 0.1)
|
222
222
|
unicode-display_width (1.6.1)
|
223
|
-
websocket-driver (0.7.
|
223
|
+
websocket-driver (0.7.3)
|
224
224
|
websocket-extensions (>= 0.1.0)
|
225
|
-
websocket-extensions (0.1.
|
225
|
+
websocket-extensions (0.1.5)
|
226
226
|
zeitwerk (2.3.0)
|
227
227
|
|
228
228
|
PLATFORMS
|
data/README.md
CHANGED
@@ -61,6 +61,9 @@ And then execute: $ bundle install
|
|
61
61
|
```
|
62
62
|
Note: Publishers do not need todo this
|
63
63
|
|
64
|
+
- Check the service status with:
|
65
|
+
```PubSubModelSync::MessagePublisher.publish_data('Test message', {sample_value: 10}, :create)```
|
66
|
+
|
64
67
|
## Examples
|
65
68
|
```ruby
|
66
69
|
# App 1 (Publisher)
|
@@ -153,9 +156,13 @@ Note: Be careful with collision of names
|
|
153
156
|
```User.ps_subscriber(action_name)```
|
154
157
|
* action_name (default :create, :sym): can be :create, :update, :destroy
|
155
158
|
|
156
|
-
- Inspect all configured subscribers
|
159
|
+
- Inspect all configured subscribers
|
157
160
|
```PubSubModelSync::Config.subscribers```
|
158
161
|
|
162
|
+
- Permit to customize the way to detect if the subscribed model was changed (Only for update action).
|
163
|
+
```.ps_subscriber_changed?(data)```
|
164
|
+
By default: ```model.changed?```
|
165
|
+
|
159
166
|
### Publishers
|
160
167
|
- Permit to configure crud publishers
|
161
168
|
```ps_publish(attrs, actions: nil, as_klass: nil)```
|
@@ -64,8 +64,7 @@ module PubSubModelSync
|
|
64
64
|
|
65
65
|
def ps_register_callback(action, publisher)
|
66
66
|
after_commit(on: action) do |model|
|
67
|
-
|
68
|
-
!model.ps_skip_callback?(action)
|
67
|
+
unless model.ps_skip_callback?(action)
|
69
68
|
klass = PubSubModelSync::MessagePublisher
|
70
69
|
klass.publish_model(model, action.to_sym, publisher)
|
71
70
|
end
|
@@ -37,7 +37,7 @@ module PubSubModelSync
|
|
37
37
|
model.destroy!
|
38
38
|
else
|
39
39
|
populate_model(model, message)
|
40
|
-
return if action == :update && !model.
|
40
|
+
return if action == :update && !model.ps_subscriber_changed?(message)
|
41
41
|
|
42
42
|
model.save!
|
43
43
|
end
|
@@ -59,7 +59,6 @@ module PubSubModelSync
|
|
59
59
|
|
60
60
|
def populate_model(model, message)
|
61
61
|
values = message.slice(*attrs)
|
62
|
-
puts "===========values: #{values.inspect}-------#{message.inspect}"
|
63
62
|
values.each do |attr, value|
|
64
63
|
model.send("#{attr}=", value)
|
65
64
|
end
|
@@ -6,6 +6,11 @@ module PubSubModelSync
|
|
6
6
|
base.extend(ClassMethods)
|
7
7
|
end
|
8
8
|
|
9
|
+
# check if model was changed to .save!
|
10
|
+
def ps_subscriber_changed?(_data)
|
11
|
+
changed?
|
12
|
+
end
|
13
|
+
|
9
14
|
module ClassMethods
|
10
15
|
def ps_subscribe(attrs, actions: nil, from_klass: name, id: :id)
|
11
16
|
settings = { id: id, from_klass: from_klass }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pub_sub_model_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -131,7 +131,7 @@ metadata:
|
|
131
131
|
homepage_uri: https://github.com/owen2345/pub_sub_model_sync
|
132
132
|
source_code_uri: https://github.com/owen2345/pub_sub_model_sync
|
133
133
|
changelog_uri: https://github.com/owen2345/pub_sub_model_sync/blob/master/CHANGELOG.md
|
134
|
-
post_install_message:
|
134
|
+
post_install_message:
|
135
135
|
rdoc_options: []
|
136
136
|
require_paths:
|
137
137
|
- lib
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
149
|
rubygems_version: 3.0.8
|
150
|
-
signing_key:
|
150
|
+
signing_key:
|
151
151
|
specification_version: 4
|
152
152
|
summary: Permit to sync models between apps through pub/sub
|
153
153
|
test_files: []
|