def initialize(name, options = {})
@name = name.to_s
@table_exists = nil
@table_alias = nil
@christener = Sql::Christener.new
@attributes = nil
@matching_attributes = nil
if options.is_a?(Hash)
@options = options
@engine = options[:engine] || Table.engine
if options[:as]
as = options[:as].to_s
@table_alias = as unless as == @name
end
else
@engine = options
end
if @engine.connection
begin
require "arel/engines/sql/compilers/#{@engine.adapter_name.downcase}_compiler"
rescue LoadError
begin
require "#{@engine.adapter_name.downcase}/arel_compiler"
rescue LoadError
raise "#{@engine.adapter_name} is not supported by Arel."
end
end
@@tables ||= engine.connection.tables
end
end