Method: Synced::Model#synchronize
- Defined in:
- lib/synced/model.rb
#synchronize(scope: scope_from_relation, strategy: synced_strategy, **options) ⇒ Object
Performs synchronization of given remote objects to local database.
website.rentals.synchronize(remote: remote_rentals)
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/synced/model.rb', line 120 def synchronize(scope: scope_from_relation, strategy: synced_strategy, **) .assert_valid_keys(:api, :fields, :include, :remote, :remove, :query_params, :association_sync, :auto_paginate, :transaction_per_page) [:remove] = synced_remove unless .has_key?(:remove) [:include] = Array.wrap(synced_include) unless .has_key?(:include) [:fields] = Array.wrap(synced_fields) unless .has_key?(:fields) [:query_params] = synced_query_params unless .has_key?(:query_params) [:auto_paginate] = synced_auto_paginate unless .has_key?(:auto_paginate) [:transaction_per_page] = synced_transaction_per_page unless .has_key?(:transaction_per_page) .merge!({ scope: scope, id_key: synced_id_key, synced_data_key: synced_data_key, data_key: synced_data_key, local_attributes: synced_local_attributes, associations: synced_associations, only_updated: synced_only_updated, mapper: synced_mapper, globalized_attributes: synced_globalized_attributes, initial_sync_since: synced_initial_sync_since, timestamp_strategy: , handle_processed_objects_proc: synced_handle_processed_objects_proc, tolerance: synced_tolerance, synced_endpoint: synced_endpoint }) Synced::Synchronizer.new(self, strategy: strategy, **).perform end |