blob: 9acb8ae3c6b514aa486afa23838e159e3f7017b7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
module Arel
class Where < Compound
attributes :relation, :predicate
deriving :==
def initialize(relation, *predicates, &block)
predicate = block_given?? yield(self) : predicates.shift
@relation = predicates.empty?? relation : Where.new(relation, *predicates)
@predicate = predicate.bind(@relation)
end
def wheres
@wheres ||= (relation.wheres + [predicate]).collect { |p| p.bind(self) }
end
end
end
|