module RR::Committers

Committers are classes that implement transaction policies. This module provides functionality to register committers and access the list of registered committers. Every Committer needs to register itself with Committers#register. Each Committer must implement at the following methods:

# Creates a new committer
#   * session: a Session object representing the current database session
def initialize(session)

# Inserts the specified record in the specified +database+ (either :left or :right).
# +table+ is the name of the target table.
# +values+ is a hash of column_name => value pairs.
def insert_record(database, values)

# Updates the specified record in the specified +database+ (either :left or :right).
# +table+ is the name of the target table.
# +values+ is a hash of column_name => value pairs.
# +old_key+ is a column_name => value hash with the original primary key.
# If +old_key+ is +nil+, then the primary key must be contained in +values+.
def update_record(database, values, old_key)

# Deletes the specified record in the specified +database+ (either :left or :right).
# +table+ is the name of the target table.
# +values+ is a hash of column_name => value pairs. (Only the primary key
# values will be used and must be included in the hash.)
def delete_record(database, values)

# Is called after the last insert / update / delete query.
def finalize

Public Class Methods

committers() click to toggle source

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

# File lib/rubyrep/committers/committers.rb, line 36
def self.committers
  @committers ||= {}
  @committers
end
register(committer_hash) click to toggle source

Registers one or multiple committers. committer_hash is a Hash with

key::   The adapter symbol as used to reference the committer
value:: The class implementing the committer
# File lib/rubyrep/committers/committers.rb, line 45
def self.register(committer_hash)
  @committers ||= {}
  @committers.merge! committer_hash
end