module RR::Syncers

Syncers are classes that implement the sync policies. This module provides functionality to register syncers and access the list of registered syncers. Each Syncer must register itself with Syncers#register. Each Syncer must implement the following methods:

# Creates a new syncer (A syncer is used for one table sync only)
#   * sync_helper: a SyncHelper object providing necessary information and functionalities
def initialize(sync_helper)

# Called to sync the provided difference.
# See DirectTableScan#run for a description of the +type+ and +row+ parameters.
def sync_difference(type, row)

# Provides default option for the syncer. Optional.
# Returns a hash with :key => value pairs.
def self.default_options

Public Class Methods

configured_syncer(options) click to toggle source

Returns the correct syncer class as per provided options hash

# File lib/rubyrep/syncers/syncers.rb, line 37
def self.configured_syncer(options)
  syncer_id = options[:syncer]
  syncer_id ||= options[:replicator]
  syncers[syncer_id]
end
register(syncer_hash) click to toggle source

Registers one or multiple syncers. syncer_hash is a Hash with

key::   The adapter symbol as used to reference the syncer
value:: The class implementing the syncer
# File lib/rubyrep/syncers/syncers.rb, line 31
def self.register(syncer_hash)
  @syncers ||= {}
  @syncers.merge! syncer_hash
end
syncers() click to toggle source

Returns a Hash of currently registered syncers. (Empty Hash if no syncers were defined.)

# File lib/rubyrep/syncers/syncers.rb, line 22
def self.syncers
  @syncers ||= {}
  @syncers
end