Parent

Included Modules

Files

Class Index [+]

Quicksearch

Arel::Table

Attributes

name[R]
engine[R]
table_alias[R]
options[R]
christener[R]

Public Class Methods

engine() click to toggle source
   # File lib/arel/engines/sql/relations/table.rb, line 8
8:       def engine; @@engine; end
engine=(e;) click to toggle source
   # File lib/arel/engines/sql/relations/table.rb, line 9
9:       def engine= e; @@engine = e; end
new(name, options = {}) click to toggle source
    # 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
tables() click to toggle source
    # File lib/arel/engines/sql/relations/table.rb, line 11
11:       def tables; @@tables; end
tables=(e;) click to toggle source
    # File lib/arel/engines/sql/relations/table.rb, line 12
12:       def tables= e; @@tables = e; end

Public Instance Methods

as(table_alias) click to toggle source
    # 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
attributes() click to toggle source
    # 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
column_for(attribute) click to toggle source
    # 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
columns() click to toggle source
    # File lib/arel/engines/sql/relations/table.rb, line 77
77:     def columns
78:       @columns ||= engine.connection.columns(name, "#{name} Columns")
79:     end
reset() click to toggle source
    # File lib/arel/engines/sql/relations/table.rb, line 81
81:     def reset
82:       @columns = nil
83:       @attributes = Header.new([])
84:     end
table_exists?() click to toggle source
    # File lib/arel/engines/sql/relations/table.rb, line 57
57:     def table_exists?
58:       @table_exists ||= @@tables.include?(name) || engine.connection.table_exists?(name)
59:     end

Private Instance Methods

has_attribute?(attribute) click to toggle source
    # File lib/arel/engines/sql/relations/table.rb, line 91
91:     def has_attribute?(attribute)
92:       matching_attributes.key? attribute.root
93:     end
matching_attributes() click to toggle source
    # File lib/arel/engines/sql/relations/table.rb, line 87
87:     def matching_attributes
88:       @matching_attributes ||= Hash[attributes.map { |a| [a.root, true] }]
89:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.