external_services 0.1.5 → 0.1.6
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,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDU3NjA4NTljMWEwODUxMDRiNzM4YjYzZGU1YzQ4NTRhZDkzOGMwOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTVhY2JhMjUzM2NhZjJiMDkyODM3MWRkZDZhN2UxM2ViMTc2YTZiNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTQxOTVkYzNiZDZhZGRiNmY1MzE1NmE4YTBlYTlhZGUxMzhjYTc5NTNlNDE4
|
10
|
+
Mjg3YzhlNTQyMjgxZjY2ZDU1ZTk5M2RlYTAyNWUyNDg4YzUxOTQ2Yjc3MTJk
|
11
|
+
Njc2ZTExYTJmMmE1ZThiMGVlZGFkYWRlM2JiZjlhNGY5NjlmY2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGEyNzQ2ZmEyMmU4NWMxZmZhY2M2ODVlMmJmZGJkZWQ4MDU3NGY3NDdiOGY1
|
14
|
+
YzNiNDE3OGE4YTE1MDRiNTIzZThkMjk3OGMzMTZmNDVkMmY5ZmMyN2IwYTdl
|
15
|
+
NzQyYTQ2ZjI0NzgwYTZkM2QwNTMwNmVjOGIxNmEyNTBiNzlhNDc=
|
data/config/locales/en.yml
CHANGED
@@ -102,8 +102,8 @@ module ExternalServices
|
|
102
102
|
public_send(:"build_#{service_assoc}") if public_send(service_assoc).blank?
|
103
103
|
end
|
104
104
|
|
105
|
-
before_update :
|
106
|
-
before_destroy :
|
105
|
+
before_update :halt_on_external_services_syncing
|
106
|
+
before_destroy :halt_on_external_services_syncing
|
107
107
|
end
|
108
108
|
|
109
109
|
after_save :"#{name}_on_create", if: :id_changed?
|
@@ -134,9 +134,9 @@ module ExternalServices
|
|
134
134
|
end
|
135
135
|
protected :"#{name}_on_revive"
|
136
136
|
|
137
|
-
protected def
|
138
|
-
|
139
|
-
errors.add :base, :
|
137
|
+
protected def halt_on_external_services_syncing
|
138
|
+
if external_services_syncing?
|
139
|
+
errors.add :base, :external_services_sync_in_process
|
140
140
|
if ::ActiveRecord::VERSION::MAJOR < 5
|
141
141
|
return false
|
142
142
|
else
|
@@ -153,6 +153,7 @@ module ExternalServices
|
|
153
153
|
def define_external_service_sync_methods(name, _options = {})
|
154
154
|
service_assoc = :"#{name}_service"
|
155
155
|
synced_method = :"#{name}_service_synced?"
|
156
|
+
syncing_method = :"#{name}_service_syncing?"
|
156
157
|
disabled_method = :"#{name}_api_disabled"
|
157
158
|
|
158
159
|
syncs_module = Module.new do
|
@@ -162,11 +163,22 @@ module ExternalServices
|
|
162
163
|
public_send(service_assoc).external_id?
|
163
164
|
end
|
164
165
|
|
166
|
+
define_method syncing_method do
|
167
|
+
action_class = "ExternalServices::ApiActions::#{name.to_s.camelize}".constantize
|
168
|
+
action_class.to_create(self).unprocessed.exists?
|
169
|
+
end
|
170
|
+
|
165
171
|
define_method :external_services_synced? do
|
166
172
|
result = (!defined?(super) || super())
|
167
173
|
result &&= public_send(synced_method) unless public_send(disabled_method)
|
168
174
|
result
|
169
175
|
end
|
176
|
+
|
177
|
+
define_method :external_services_syncing? do
|
178
|
+
result = (!defined?(super) || super())
|
179
|
+
result &&= public_send(syncing_method) unless public_send(disabled_method)
|
180
|
+
result
|
181
|
+
end
|
170
182
|
end
|
171
183
|
|
172
184
|
include syncs_module
|