This syncer implements a one way sync. Syncer options relevant for this syncer:
* +:direction+: Sync direction. Possible values: * +:left+ * +:right+ * +:delete+: Default: false. If true, deletes in the target database all records _not_ existing in the source database. * +:update+: If true (default), update records in the target database if different. * +:insert+: If true (default), copy over records not existing in the target database.
Array index to source row in case sync_difference type is :conflict. (As in that case the row parameter is an array of left and right records.)
Provides default option for the syncer. Optional. Returns a hash with :key => value pairs.
# File lib/rubyrep/syncers/syncers.rb, line 74 def self.default_options { :direction => :right, :delete => false, :update => true, :insert => true } end
Initializes the syncer
* sync_helper: The SyncHelper object provided information and utility functions.
# File lib/rubyrep/syncers/syncers.rb, line 84 def initialize(sync_helper) self.sync_helper = sync_helper self.source = sync_helper.sync_options[:direction] == :left ? :right : :left self.target = sync_helper.sync_options[:direction] == :left ? :left : :right self.source_record_index = sync_helper.sync_options[:direction] == :left ? 1 : 0 end
Called to sync the provided difference. See DirectTableScan#run for a description of the type and row parameters.
# File lib/rubyrep/syncers/syncers.rb, line 93 def sync_difference(type, row) case type when source if sync_helper.sync_options[:insert] sync_helper.insert_record target, sync_helper.tables[target], row end when target if sync_helper.sync_options[:delete] sync_helper.delete_record target, sync_helper.tables[target], row end when :conflict if sync_helper.sync_options[:update] sync_helper.update_record target, sync_helper.tables[target], row[source_record_index] end end end
Generated with the Darkfish Rdoc Generator 2.