Module: RR::Syncers

Defined in:
lib/rubyrep/syncers/syncers.rb,
lib/rubyrep/syncers/two_way_syncer.rb

Overview

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

Defined Under Namespace

Classes: OneWaySyncer, TwoWaySyncer

Class Method Summary collapse

Class Method Details

.configured_syncer(options) ⇒ Object

Returns the correct syncer class as per provided options hash



37
38
39
40
41
# 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) ⇒ Object

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


31
32
33
34
# File 'lib/rubyrep/syncers/syncers.rb', line 31

def self.register(syncer_hash)
  @syncers ||= {}
  @syncers.merge! syncer_hash
end

.syncersObject

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



22
23
24
25
# File 'lib/rubyrep/syncers/syncers.rb', line 22

def self.syncers
  @syncers ||= {}
  @syncers
end