diff options
Diffstat (limited to 'lib/arel/relations/operations/where.rb')
-rw-r--r-- | lib/arel/relations/operations/where.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/arel/relations/operations/where.rb b/lib/arel/relations/operations/where.rb new file mode 100644 index 0000000000..ba34846c04 --- /dev/null +++ b/lib/arel/relations/operations/where.rb @@ -0,0 +1,21 @@ +module Arel + class Where < Compound + attr_reader :predicate + + def initialize(relation, *predicates) + predicate = 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 + + def ==(other) + Where === other and + relation == other.relation and + predicate == other.predicate + end + end +end
\ No newline at end of file |