blob: 2fc51c7f24e3fa83d47330b4e7e141a72b86ba60 (
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 Arel
class Where < Compound
attributes :relation, :predicate
deriving :==
def initialize(relation, *predicates, &block)
predicate = block_given?? yield(relation) : predicates.shift
@relation = predicates.empty?? relation : Where.new(relation, *predicates)
@predicate = predicate.bind(@relation)
end
def engine
# Temporary check of whether or not the engine supports where.
if relation.engine.respond_to?(:supports) && !relation.engine.supports(:where)
Memory::Engine.new
else
relation.engine
end
end
def wheres
@wheres ||= (relation.wheres + [predicate]).collect { |p| p.bind(self) }
end
end
end
|