aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/memory
diff options
context:
space:
mode:
authorErnie Miller <ernie@metautonomo.us>2010-04-09 19:52:43 -0400
committerErnie Miller <ernie@metautonomo.us>2010-05-07 13:07:43 -0400
commitbd473344000bd538d353e4bc6d20ca8fff2e4704 (patch)
treec2586b9dc543aa828dcbefd2769e7a1d7485280a /lib/arel/engines/memory
parent0433b054eebd5a53ff6c5f35383a6c0aed0015b2 (diff)
downloadrails-bd473344000bd538d353e4bc6d20ca8fff2e4704.tar.gz
rails-bd473344000bd538d353e4bc6d20ca8fff2e4704.tar.bz2
rails-bd473344000bd538d353e4bc6d20ca8fff2e4704.zip
Support predicate complements and alternate not syntax (overload BasicObject#!)
Diffstat (limited to 'lib/arel/engines/memory')
-rw-r--r--lib/arel/engines/memory/predicates.rb39
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