blob: 3aa06406cfd91dd875d0ddae3d7cfe7b50101731 (
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
35
36
37
|
module Arel
class Where < Compound
attr_reader :predicates
def initialize(relation, *predicates)
super(relation)
@predicates = predicates.map { |p| p.bind(relation) }
@wheres = nil
end
def wheres
@wheres ||= relation.wheres + predicates
end
def == other
super ||
Where === other &&
relation == other.relation &&
predicates == other.predicates
end
def engine
engine = relation.engine
# Temporary check of whether or not the engine supports where.
if engine.respond_to?(:supports) && !engine.supports(:restricting)
Memory::Engine.new
else
engine
end
end
def eval
unoperated_rows.select { |row| predicates.all? { |p| p.eval(row) } }
end
end
end
|