blob: 6c9c5ed75586f83e47f434b54491b2b1f4523a6e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
module Arel
class Where < Compound
attributes :relation, :predicate
deriving :==
requires :restricting
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 wheres
@wheres ||= (relation.wheres + [predicate]).collect { |p| p.bind(self) }
end
end
end
|