synced 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/synced/strategies/check.rb +9 -4
- data/lib/synced/strategies/full.rb +9 -12
- 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: 3b57fd9809319aece800d98be7cb7d595af42183
|
4
|
+
data.tar.gz: ceb98bf9015b4877d597f4d89a73c63627ad8353
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 498ac45444e90dac7dba56d8c79bb644c61a89fd5da85c1225612a86dc0d5fae59cb6570d744d2c5c7b4d3176dd0936c36d304f7aadfa97d672bd4b2a4b38125
|
7
|
+
data.tar.gz: 43493baddef335a7c0602949071ba5602cc0e9519e746fc7f737f86a9fc327a8c6d5dda260bc2ec68249d060e3293dc67a5aac0100cde3527dd4300b49fd0988
|
@@ -25,11 +25,16 @@ module Synced
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def remote_objects_tester
|
28
|
-
lambda do |
|
29
|
-
|
28
|
+
lambda do |remote_objects_batch|
|
29
|
+
remote_objects_batch_ids = remote_objects_batch.map(&:id)
|
30
|
+
local_objects = relation_scope.where(@id_key => remote_objects_batch_ids)
|
31
|
+
local_objects_hash = local_objects.each_with_object({}) do |local_object, hash|
|
32
|
+
hash[local_object.public_send(@id_key)] = local_object
|
33
|
+
end
|
34
|
+
@remote_objects_ids.concat(remote_objects_batch_ids)
|
30
35
|
|
31
|
-
|
32
|
-
if local_object =
|
36
|
+
remote_objects_batch.map do |remote|
|
37
|
+
if local_object = local_objects_hash[remote.id]
|
33
38
|
remote.extend(@mapper) if @mapper
|
34
39
|
local_object.attributes = default_attributes_mapping(remote)
|
35
40
|
local_object.attributes = local_attributes_mapping(remote)
|
@@ -89,14 +89,19 @@ module Synced
|
|
89
89
|
private
|
90
90
|
|
91
91
|
def remote_objects_persistor
|
92
|
-
lambda do |
|
92
|
+
lambda do |remote_objects_batch|
|
93
93
|
additional_errors_check
|
94
|
-
|
94
|
+
remote_objects_batch_ids = remote_objects_batch.map(&:id)
|
95
|
+
local_objects = relation_scope.where(@id_key => remote_objects_batch_ids)
|
96
|
+
local_objects_hash = local_objects.each_with_object({}) do |local_object, hash|
|
97
|
+
hash[local_object.public_send(@id_key)] = local_object
|
98
|
+
end
|
99
|
+
@remote_objects_ids.concat(remote_objects_batch_ids)
|
95
100
|
|
96
101
|
processed_objects =
|
97
|
-
|
102
|
+
remote_objects_batch.map do |remote|
|
98
103
|
remote.extend(@mapper) if @mapper
|
99
|
-
local_object =
|
104
|
+
local_object = local_objects_hash[remote.id] || relation_scope.new
|
100
105
|
local_object.attributes = default_attributes_mapping(remote)
|
101
106
|
local_object.attributes = local_attributes_mapping(remote)
|
102
107
|
if @globalized_attributes.present?
|
@@ -172,14 +177,6 @@ module Synced
|
|
172
177
|
@api ||= closest.try(:api) || raise(MissingAPIClient.new(@scope, @model_class))
|
173
178
|
end
|
174
179
|
|
175
|
-
def local_object_by_remote_id(remote_id)
|
176
|
-
local_objects.find { |l| l.public_send(@id_key) == remote_id }
|
177
|
-
end
|
178
|
-
|
179
|
-
def local_objects
|
180
|
-
relation_scope.where(@id_key => remote_objects_ids).to_a
|
181
|
-
end
|
182
|
-
|
183
180
|
def remote_objects_ids
|
184
181
|
@remote_objects_ids
|
185
182
|
end
|
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.5.
|
4
|
+
version: 1.5.2
|
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: 2017-
|
12
|
+
date: 2017-03-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|