synced 1.7.0 → 1.8.0

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: 9d07dc9160fbcc981a1b08e986c8b732768b3912
4
- data.tar.gz: 6ad287a51fd7465e84120d34c230d0359ef7afe1
3
+ metadata.gz: 93effbb9923e23f138e7b82c9faf2a6f2bf22c65
4
+ data.tar.gz: bcd9e233e82e9601bbab880a79403d18b4a2f389
5
5
  SHA512:
6
- metadata.gz: 0381da8af658da381a11eb0fcc3b2f764a0e90e20c6fb5df03e6fc33d3755c1f39bdd4451c94461779ecb66140e6e60940e71781714ed1cf3431a038344a6c3b
7
- data.tar.gz: 8c30d25d30aebb37edd4f1eb3b331795bce23efbcdda85331468f9c01b220b08ae3c97bac7e25fd9e157329e9816d8c4a1327cf8df2eb66533b7139d39245980
6
+ metadata.gz: 396006e583aad103b778d7b95018aeed916cc163a08deb071722855be7dae57348f5a5e6a78a2b39d96ceb7b8fc705b98910543e01933fa6f11b45b15037b200
7
+ data.tar.gz: 376b82eb69c737606f6cda84ea550cd6d71397769dc710674d16c3d3c9cf1da3f54b41bf70a1f5abb7a2e17c9ae9f2fe0af680341f41baf3f31ac6a599062480
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Code Climate](https://codeclimate.com/github/BookingSync/synced.png)](https://codeclimate.com/github/BookingSync/synced)
1
+ ©[![Code Climate](https://codeclimate.com/github/BookingSync/synced.png)](https://codeclimate.com/github/BookingSync/synced)
2
2
  [![Build Status](https://travis-ci.org/BookingSync/synced.png?branch=master)](https://travis-ci.org/BookingSync/synced)
3
3
 
4
4
  # Synced
@@ -500,6 +500,9 @@ Or as a param in `synchronize` method:
500
500
  Photo.synchronize(transaction_per_page: true)
501
501
  ```
502
502
 
503
+ ## Model Aliasing
504
+ By default `synced` gem will look for an endpoint in BookingSync with the same name as it was defined in. If you want to name your class differently or place it in a namespace, provide endpoint of resource that you want to access with the `endpoint` option. Like so: `synced endpoint: :bookings`.
505
+
503
506
  ## Synced configuration options
504
507
 
505
508
  Option name | Default value | Description | synced | synchronize |
@@ -518,6 +521,7 @@ Option name | Default value | Description
518
521
  `:transaction_per_page` | `false` | [Whether transaction should be per page of fetched objects or for all the pages - note that setting this value to `true` will mean always fetching data in batches, even when specifying `auto_paginate` as true](#persisting-fetched-objects) | YES | YES |
519
522
  `:handle_processed_objects_proc` | `nil` | [Custom proc taking persisted remote objects, called after persisting batch of data](#persisted-objects) | YES | NO |
520
523
  `:tolerance` | 0 | [How many seconds updated_since param should be reduced during request](#syncing-with-offset) | YES | NO |
524
+ `:endpoint` | `table name of the class it was defined in` | endpoint for synchronizeable resource on BookingSync | YES | NO |
521
525
 
522
526
  ## Documentation
523
527
 
@@ -50,13 +50,13 @@ module Synced
50
50
  options.assert_valid_keys(:associations, :data_key, :fields, :globalized_attributes,
51
51
  :id_key, :include, :initial_sync_since, :local_attributes, :mapper, :only_updated,
52
52
  :remove, :auto_paginate, :transaction_per_page, :delegate_attributes, :query_params,
53
- :timestamp_strategy, :handle_processed_objects_proc, :tolerance)
53
+ :timestamp_strategy, :handle_processed_objects_proc, :tolerance, :endpoint)
54
54
  class_attribute :synced_id_key, :synced_data_key,
55
55
  :synced_local_attributes, :synced_associations, :synced_only_updated,
56
56
  :synced_mapper, :synced_remove, :synced_include, :synced_fields, :synced_auto_paginate, :synced_transaction_per_page,
57
57
  :synced_globalized_attributes, :synced_initial_sync_since, :synced_delegate_attributes,
58
58
  :synced_query_params, :synced_timestamp_strategy, :synced_strategy, :synced_handle_processed_objects_proc,
59
- :synced_tolerance
59
+ :synced_tolerance, :synced_endpoint
60
60
  self.synced_strategy = strategy
61
61
  self.synced_id_key = options.fetch(:id_key, :synced_id)
62
62
  self.synced_data_key = options.fetch(:data_key) { synced_column_presence(:synced_data) }
@@ -78,6 +78,7 @@ module Synced
78
78
  self.synced_transaction_per_page = options.fetch(:transaction_per_page, false)
79
79
  self.synced_handle_processed_objects_proc = options.fetch(:handle_processed_objects_proc, nil)
80
80
  self.synced_tolerance = options.fetch(:tolerance, 0).to_i.abs
81
+ self.synced_endpoint = options.fetch(:endpoint) { self.to_s.tableize }
81
82
  include Synced::DelegateAttributes
82
83
  include Synced::HasSyncedData
83
84
  end
@@ -138,7 +139,8 @@ module Synced
138
139
  initial_sync_since: synced_initial_sync_since,
139
140
  timestamp_strategy: synced_timestamp_strategy,
140
141
  handle_processed_objects_proc: synced_handle_processed_objects_proc,
141
- tolerance: synced_tolerance
142
+ tolerance: synced_tolerance,
143
+ synced_endpoint: synced_endpoint
142
144
  })
143
145
  Synced::Synchronizer.new(self, options).perform
144
146
  end
@@ -153,7 +155,8 @@ module Synced
153
155
  strategy: synced_strategy,
154
156
  only_updated: synced_only_updated,
155
157
  initial_sync_since: synced_initial_sync_since,
156
- timestamp_strategy: synced_timestamp_strategy
158
+ timestamp_strategy: synced_timestamp_strategy,
159
+ synced_endpoint: synced_endpoint
157
160
  }
158
161
  Synced::Synchronizer.new(self, options).reset_synced
159
162
  end
@@ -172,4 +175,3 @@ module Synced
172
175
  end
173
176
  end
174
177
  end
175
-
@@ -49,6 +49,7 @@ module Synced
49
49
  # of fetched records
50
50
  def initialize(model_class, options = {})
51
51
  @model_class = model_class
52
+ @synced_endpoint = options[:synced_endpoint]
52
53
  @scope = options[:scope]
53
54
  @id_key = options[:id_key]
54
55
  @data_key = options[:data_key]
@@ -198,18 +199,18 @@ module Synced
198
199
  def fetch_and_save_remote_objects(processor)
199
200
  instrument("fetch_remote_objects.synced", model: @model_class) do
200
201
  if @transaction_per_page
201
- api.paginate(resource_name, api_request_options) do |batch|
202
+ api.paginate(@synced_endpoint, api_request_options) do |batch|
202
203
  relation_scope.transaction do
203
204
  processor.call(batch)
204
205
  end
205
206
  end
206
207
  elsif @auto_paginate
207
208
  relation_scope.transaction do
208
- processor.call(api.paginate(resource_name, api_request_options))
209
+ processor.call(api.paginate(@synced_endpoint, api_request_options))
209
210
  end
210
211
  else
211
212
  relation_scope.transaction do
212
- api.paginate(resource_name, api_request_options) do |batch|
213
+ api.paginate(@synced_endpoint, api_request_options) do |batch|
213
214
  processor.call(batch)
214
215
  end
215
216
  end
@@ -1,3 +1,3 @@
1
1
  module Synced
2
- VERSION = "1.7.0"
2
+ VERSION = "1.8.0"
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.7.0
4
+ version: 1.8.0
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: 2018-02-27 00:00:00.000000000 Z
12
+ date: 2018-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  version: '0'
239
239
  requirements: []
240
240
  rubyforge_project:
241
- rubygems_version: 2.6.14
241
+ rubygems_version: 2.5.1
242
242
  signing_key:
243
243
  specification_version: 4
244
244
  summary: Keep your BookingSync Application synced with BookingSync.