blob: d85c2680198ae5ed0bbcdfe97692cd32169dd85c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
module ActiveRelation
class Table < Relation
attr_reader :name
def initialize(name)
@name = name
end
def attributes
@attributes ||= connection.columns(name, "#{name} Columns").collect do |column|
Attribute.new(self, column.name.to_sym)
end
end
def qualify
Rename.new self, qualifications
end
def prefix_for(attribute)
self[attribute] and name
end
alias_method :aliased_prefix_for, :prefix_for
protected
def table_sql
"#{quote_table_name(name)}"
end
private
def qualifications
attributes.zip(attributes.collect(&:qualified_name)).to_hash
end
end
end
|