class SQLExporter

This class implements the interface for exprting SQLConstructor objects to strings.

Constants

DEFAULT_DIALECT

defaults to 'mysql'

Attributes

dialect[RW]
separator[R]
tidy[RW]

Public Class Methods

new( dialect = DEFAULT_DIALECT, tidy = false ) click to toggle source

Class constructor. Called with two optional arguments - dialect and tidy. Dialect determines the translator class (e.g., Exporter_mysql, Exporter_informix etc). Tidy determines whether the output should be formatted and human-readable.

# File lib/sqlexporter.rb, line 19
def initialize ( dialect = DEFAULT_DIALECT, tidy = false )
    dialect ||= DEFAULT_DIALECT
    dialect_class = "Exporter_" + dialect.to_s
    begin
        @translator = SQLExporter.const_get( dialect_class ).new( tidy )
    rescue
        raise NameError, ERR_UNKNOWN_DIALECT + ": " + dialect.to_s
    end
    @dialect, @tidy = dialect, tidy
    @separator = @translator.separator
end

Public Instance Methods

export( obj ) click to toggle source

The main method to export the obj to string. Calls the @translator's export method.

# File lib/sqlexporter.rb, line 35
def export ( obj )
    string = @translator.export obj
    string = @separator + "(" + string + ")"  if obj.inline
    return string
end