# File lib/arel/engines/sql/relations/table.rb, line 8 8: def engine; @@engine; end
# File lib/arel/engines/sql/relations/table.rb, line 9 9: def engine= e; @@engine = e; end
# File lib/arel/engines/sql/relations/table.rb, line 17
17: def initialize(name, options = {})
18: @name = name.to_s
19: @table_exists = nil
20: @table_alias = nil
21: @christener = Sql::Christener.new
22: @attributes = nil
23: @matching_attributes = nil
24:
25: if options.is_a?(Hash)
26: @options = options
27: @engine = options[:engine] || Table.engine
28:
29: if options[:as]
30: as = options[:as].to_s
31: @table_alias = as unless as == @name
32: end
33: else
34: @engine = options # Table.new('foo', engine)
35: end
36:
37: if @engine.connection
38: begin
39: require "arel/engines/sql/compilers/#{@engine.adapter_name.downcase}_compiler"
40: rescue LoadError
41: begin
42: # try to load an externally defined compiler, in case this adapter has defined the compiler on its own.
43: require "#{@engine.adapter_name.downcase}/arel_compiler"
44: rescue LoadError
45: raise "#{@engine.adapter_name} is not supported by Arel."
46: end
47: end
48:
49: @@tables ||= engine.connection.tables
50: end
51: end
# File lib/arel/engines/sql/relations/table.rb, line 53
53: def as(table_alias)
54: Table.new(name, options.merge(:as => table_alias))
55: end
# File lib/arel/engines/sql/relations/table.rb, line 61
61: def attributes
62: return @attributes if @attributes
63: if table_exists?
64: attrs = columns.collect do |column|
65: Sql::Attributes.for(column).new(column, self, column.name.to_sym)
66: end
67: @attributes = Header.new(attrs)
68: else
69: Header.new
70: end
71: end
# File lib/arel/engines/sql/relations/table.rb, line 73
73: def column_for(attribute)
74: has_attribute?(attribute) and columns.detect { |c| c.name == attribute.name.to_s }
75: end
# File lib/arel/engines/sql/relations/table.rb, line 77
77: def columns
78: @columns ||= engine.connection.columns(name, "#{name} Columns")
79: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.