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
35
36
37
38
39
40
41
42
43
44
45
|
class Attribute
attr_reader :relation, :attribute_name, :aliaz
def initialize(relation, attribute_name, aliaz = nil)
@relation, @attribute_name, @aliaz = relation, attribute_name, aliaz
end
def aliazz(aliaz)
Attribute.new(relation, attribute_name, aliaz)
end
def eql?(other)
relation == other.relation and attribute_name == other.attribute_name
end
def ==(other)
EqualityPredicate.new(self, other)
end
def <(other)
LessThanPredicate.new(self, other)
end
def <=(other)
LessThanOrEqualToPredicate.new(self, other)
end
def >(other)
GreaterThanPredicate.new(self, other)
end
def >=(other)
GreaterThanOrEqualToPredicate.new(self, other)
end
def =~(regexp)
MatchPredicate.new(self, regexp)
end
def to_sql(builder = SelectsBuilder.new)
builder.call do
column relation.table, attribute_name, aliaz
end
end
end
|