aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-21 10:34:11 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-21 10:34:11 -0700
commit2f0a8ae8d4aed502a0b6c4780d4545c147bdcb47 (patch)
tree601c2aef98a6fedd5b8a6322685bc300c50c42b9 /lib/arel/algebra
parent862067cf14213ee9df0784250301a1987b3822db (diff)
downloadrails-2f0a8ae8d4aed502a0b6c4780d4545c147bdcb47.tar.gz
rails-2f0a8ae8d4aed502a0b6c4780d4545c147bdcb47.tar.bz2
rails-2f0a8ae8d4aed502a0b6c4780d4545c147bdcb47.zip
fixing incompatibilities with AR
Diffstat (limited to 'lib/arel/algebra')
-rw-r--r--lib/arel/algebra/predicates.rb28
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/arel/algebra/predicates.rb b/lib/arel/algebra/predicates.rb
index 1b9667ac13..b761eab417 100644
--- a/lib/arel/algebra/predicates.rb
+++ b/lib/arel/algebra/predicates.rb
@@ -1,6 +1,6 @@
module Arel
module Predicates
- class Predicate < Struct.new(:children)
+ class Predicate
def or(other_predicate)
Or.new(self, other_predicate)
end
@@ -16,17 +16,13 @@ module Arel
def not
self.complement
end
-
- def == other
- super || (self.class === other && children == other.children)
- end
end
class Polyadic < Predicate
- alias :predicates :children
+ attr_reader :predicates
def initialize(*predicates)
- super(predicates)
+ @predicates = predicates
end
# Build a Polyadic predicate based on:
@@ -42,6 +38,10 @@ module Arel
)
end
+ def ==(other)
+ super || predicates == other.predicates
+ end
+
def bind(relation)
self.class.new(
*predicates.map {|p| p.find_correlate_in(relation)}
@@ -62,11 +62,19 @@ module Arel
end
class Unary < Predicate
- alias :operand :children
+ attr_reader :operand
+
+ def initialize operand
+ @operand = operand
+ end
def bind(relation)
self.class.new(operand.find_correlate_in(relation))
end
+
+ def == other
+ super || self.class === other && operand == other.operand
+ end
end
class Not < Unary
@@ -75,9 +83,9 @@ module Arel
end
end
- class Binary < Predicate
- alias :operand1 :children
+ class Binary < Unary
attr_reader :operand2
+ alias :operand1 :operand
def initialize left, right
super(left)