diff options
Diffstat (limited to 'lib/arel/engines/memory/predicates.rb')
-rw-r--r-- | lib/arel/engines/memory/predicates.rb | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/lib/arel/engines/memory/predicates.rb b/lib/arel/engines/memory/predicates.rb index c0ee862626..0e88810e7d 100644 --- a/lib/arel/engines/memory/predicates.rb +++ b/lib/arel/engines/memory/predicates.rb @@ -13,41 +13,40 @@ module Arel end class Not < Unary - def operator; '!' end - end - - class CompoundPredicate < Binary def eval(row) - eval "operand1.eval(row) #{operator} operand2.eval(row)" + !operand.eval(row) end end - - class Or < CompoundPredicate - def operator; :or end - end - - class And < CompoundPredicate - def operator; :and end - end - class GroupedPredicate < Polyadic + class Polyadic < Predicate def eval(row) - group = additional_operands.inject([]) do |results, operand| - results << operator.new(operand1, operand) - end - group.send(compounder) do |operation| + predicates.send(compounder) do |operation| operation.eval(row) end end end - class Any < GroupedPredicate + class Any < Polyadic def compounder; :any? end end - class All < GroupedPredicate + class All < Polyadic def compounder; :all? end end + + class CompoundPredicate < Binary + def eval(row) + eval "operand1.eval(row) #{operator} operand2.eval(row)" + end + end + + class Or < CompoundPredicate + def operator; :or end + end + + class And < CompoundPredicate + def operator; :and end + end class Equality < Binary def operator; :== end |