Parent

Included Modules

Class Index [+]

Quicksearch

Arel::Table

Attributes

engine[RW]
name[RW]
engine[RW]
aliases[RW]
table_alias[RW]

Public Class Methods

new(name, engine = Table.engine) click to toggle source
    # File lib/arel/table.rb, line 10
10:     def initialize name, engine = Table.engine
11:       @name    = name.to_s
12:       @engine  = engine
13:       @columns = nil
14:       @aliases = []
15:       @table_alias = nil
16:       @primary_key = nil
17: 
18:       if Hash === engine
19:         @engine  = engine[:engine] || Table.engine
20:         @columns = attributes_for engine[:columns]
21: 
22:         # Sometime AR sends an :as parameter to table, to let the table know
23:         # that it is an Alias.  We may want to override new, and return a
24:         # TableAlias node?
25:         @table_alias = engine[:as] unless engine[:as].to_s == @name
26:       end
27:     end

Public Instance Methods

[](name) click to toggle source
     # File lib/arel/table.rb, line 96
 96:     def [] name
 97:       return nil unless table_exists?
 98: 
 99:       name = name.to_sym
100:       columns.find { |column| column.name == name }
101:     end
alias() click to toggle source
    # File lib/arel/table.rb, line 37
37:     def alias
38:       Nodes::TableAlias.new("#{name}_2", self).tap do |node|
39:         @aliases << node
40:       end
41:     end
columns() click to toggle source
    # File lib/arel/table.rb, line 91
91:     def columns
92:       @columns ||=
93:         attributes_for @engine.connection.columns(@name, "#{@name} Columns")
94:     end
from(table) click to toggle source
    # File lib/arel/table.rb, line 43
43:     def from table
44:       SelectManager.new(@engine, table)
45:     end
group(*columns) click to toggle source
    # File lib/arel/table.rb, line 63
63:     def group *columns
64:       from(self).group(*columns)
65:     end
having(expr) click to toggle source
    # File lib/arel/table.rb, line 87
87:     def having expr
88:       from(self).having expr
89:     end
join(relation, klass = Nodes::InnerJoin) click to toggle source
    # File lib/arel/table.rb, line 51
51:     def join relation, klass = Nodes::InnerJoin
52:       return from(self) unless relation
53: 
54:       case relation
55:       when String, Nodes::SqlLiteral
56:         raise if relation.blank?
57:         from Nodes::StringJoin.new(self, relation)
58:       else
59:         from klass.new(self, relation, nil)
60:       end
61:     end
joins(manager) click to toggle source
    # File lib/arel/table.rb, line 47
47:     def joins manager
48:       nil
49:     end
order(*expr) click to toggle source
    # File lib/arel/table.rb, line 67
67:     def order *expr
68:       from(self).order(*expr)
69:     end
primary_key() click to toggle source
    # File lib/arel/table.rb, line 29
29:     def primary_key
30:       @primary_key ||= begin
31:         primary_key_name = @engine.connection.primary_key(name)
32:         # some tables might be without primary key
33:         primary_key_name && self[primary_key_name]
34:       end
35:     end
project(*things) click to toggle source
    # File lib/arel/table.rb, line 75
75:     def project *things
76:       from(self).project(*things)
77:     end
select_manager() click to toggle source
     # File lib/arel/table.rb, line 103
103:     def select_manager
104:       SelectManager.new(@engine)
105:     end
skip(amount) click to toggle source
    # File lib/arel/table.rb, line 83
83:     def skip amount
84:       from(self).skip amount
85:     end
take(amount) click to toggle source
    # File lib/arel/table.rb, line 79
79:     def take amount
80:       from(self).take amount
81:     end
where(condition) click to toggle source
    # File lib/arel/table.rb, line 71
71:     def where condition
72:       from(self).where condition
73:     end

Private Instance Methods

attributes_for(columns) click to toggle source
     # File lib/arel/table.rb, line 109
109:     def attributes_for columns
110:       return nil unless columns
111: 
112:       columns.map do |column|
113:         Attributes.for(column).new self, column.name.to_sym, column
114:       end
115:     end
table_exists?() click to toggle source
     # File lib/arel/table.rb, line 117
117:     def table_exists?
118:       @table_exists ||= tables.key?(@name) || engine.connection.table_exists?(name)
119:     end
tables() click to toggle source
     # File lib/arel/table.rb, line 121
121:     def tables
122:       self.class.table_cache(@engine)
123:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.