synced 1.0.6 → 1.0.7
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/lib/synced/synchronizer.rb +8 -10
- data/lib/synced/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7aa93a0045e49e35ef45f18f16afcd94d9e0bd24
|
|
4
|
+
data.tar.gz: 699a8ae50503c3bb5467dacc47084ce59f849c92
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 539bad5fcea8a7499960b79168d83196658a3479e953486fa70240c75e89079bf4bb3a1f12802d8edaee653fc66799cc6547db2f6a1f830fc404c4ddd1baa103
|
|
7
|
+
data.tar.gz: 4d1c9bb509766abbb41a245522b150442338f25ef23901650378a239709cb1c384fd14ed090238ff085ca6eaf2c341918c53f2476ba05e009d933608c74b7f2b
|
data/lib/synced/synchronizer.rb
CHANGED
|
@@ -58,8 +58,8 @@ module Synced
|
|
|
58
58
|
@fields = options[:fields]
|
|
59
59
|
@remove = options[:remove]
|
|
60
60
|
@associations = Array(options[:associations])
|
|
61
|
-
@
|
|
62
|
-
@
|
|
61
|
+
@perform_request = options[:remote].nil?
|
|
62
|
+
@remote_objects = Array(options[:remote]) unless @perform_request
|
|
63
63
|
@globalized_attributes = attributes_as_hash(options[:globalized_attributes])
|
|
64
64
|
@initial_sync_since = options[:initial_sync_since]
|
|
65
65
|
end
|
|
@@ -90,7 +90,7 @@ module Synced
|
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
end.tap do |local_objects|
|
|
93
|
-
if updated_since_enabled?
|
|
93
|
+
if updated_since_enabled?
|
|
94
94
|
instrument("update_synced_all_at_perform.synced", model: @model_class) do
|
|
95
95
|
relation_scope.update_all(@synced_all_at_key => Time.now)
|
|
96
96
|
end
|
|
@@ -165,19 +165,17 @@ module Synced
|
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
def remote_objects
|
|
168
|
-
@remote_objects ||= fetch_remote_objects
|
|
168
|
+
@remote_objects ||= @perform_request ? fetch_remote_objects : nil
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
def deleted_remote_objects_ids
|
|
172
|
-
remote_objects
|
|
172
|
+
remote_objects
|
|
173
173
|
api.last_response.meta[:deleted_ids]
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
def fetch_remote_objects
|
|
177
177
|
instrument("fetch_remote_objects.synced", model: @model_class) do
|
|
178
|
-
api.paginate(resource_name, api_request_options)
|
|
179
|
-
@request_performed = true
|
|
180
|
-
end
|
|
178
|
+
api.paginate(resource_name, api_request_options)
|
|
181
179
|
end
|
|
182
180
|
end
|
|
183
181
|
|
|
@@ -211,7 +209,7 @@ module Synced
|
|
|
211
209
|
end
|
|
212
210
|
|
|
213
211
|
def updated_since_enabled?
|
|
214
|
-
@only_updated && @synced_all_at_key
|
|
212
|
+
@only_updated && @synced_all_at_key && @perform_request
|
|
215
213
|
end
|
|
216
214
|
|
|
217
215
|
def resource_name
|
|
@@ -231,7 +229,7 @@ module Synced
|
|
|
231
229
|
end
|
|
232
230
|
|
|
233
231
|
def remove_relation
|
|
234
|
-
if
|
|
232
|
+
if updated_since_enabled?
|
|
235
233
|
relation_scope.where(id_key => deleted_remote_objects_ids)
|
|
236
234
|
else
|
|
237
235
|
relation_scope.where.not(id_key => remote_objects_ids)
|
data/lib/synced/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: synced
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sebastien Grosjean
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-
|
|
12
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|