blob: 701ab189d0042205cadadd20f187e8531a2b5f07 (
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
|
module ActiveRelation
class Alias < Compound
attr_reader :alias
alias_method :name, :alias
def initialize(relation, aliaz)
@relation, @alias = relation, aliaz
end
def attributes
relation.attributes.collect { |attribute| attribute.substitute(self) }
end
def ==(other)
relation == other.relation and self.alias == other.alias
end
protected
def attribute(name)
if unaliased_attribute = relation[name]
unaliased_attribute.substitute(self)
end
end
end
end
|