synced 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7d60ab7f5ecb738bb46d858dc48d7df17091de0
4
- data.tar.gz: 26077b427c696ae5354e23fa087d4be2690ca7cf
3
+ metadata.gz: 7aa93a0045e49e35ef45f18f16afcd94d9e0bd24
4
+ data.tar.gz: 699a8ae50503c3bb5467dacc47084ce59f849c92
5
5
  SHA512:
6
- metadata.gz: 7cf9b81a096a123dd070c494ba4684b327faaaa17671e3e4bb3159482a19fb914b7bd560ca15021fb10c1d5f80956b6b889c900cbe6d8e2c39897a6797e38e91
7
- data.tar.gz: f7c4f5fc0295733e235b008e79e9d1994dc1fffa289f2c9e1758ebdd50a0cc21ee6dad2c2d24cd4d640de3f537d597d69820aef844892f8940ec72547b731339
6
+ metadata.gz: 539bad5fcea8a7499960b79168d83196658a3479e953486fa70240c75e89079bf4bb3a1f12802d8edaee653fc66799cc6547db2f6a1f830fc404c4ddd1baa103
7
+ data.tar.gz: 4d1c9bb509766abbb41a245522b150442338f25ef23901650378a239709cb1c384fd14ed090238ff085ca6eaf2c341918c53f2476ba05e009d933608c74b7f2b
@@ -58,8 +58,8 @@ module Synced
58
58
  @fields = options[:fields]
59
59
  @remove = options[:remove]
60
60
  @associations = Array(options[:associations])
61
- @remote_objects = Array(options[:remote]) unless options[:remote].nil?
62
- @request_performed = false
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? && @request_performed
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 unless @request_performed
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).tap do
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 @only_updated && @request_performed
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)
@@ -1,3 +1,3 @@
1
1
  module Synced
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
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.6
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-10-28 00:00:00.000000000 Z
12
+ date: 2014-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails