aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2009-09-30 23:32:05 -0400
committerBryan Helmkamp <bryan@brynary.com>2009-09-30 23:32:05 -0400
commitbcd8ffa2183a1ca98417fb39bbd83e8f69c984c8 (patch)
tree36eac8c0fdd0a6a126a10dd7ad829401793a9379 /lib/arel/algebra
parent52e8aff146c162986566d3e03852395729d7c24d (diff)
downloadrails-bcd8ffa2183a1ca98417fb39bbd83e8f69c984c8.tar.gz
rails-bcd8ffa2183a1ca98417fb39bbd83e8f69c984c8.tar.bz2
rails-bcd8ffa2183a1ca98417fb39bbd83e8f69c984c8.zip
Create Predicates module to match directory structure
Diffstat (limited to 'lib/arel/algebra')
-rw-r--r--lib/arel/algebra/predicates.rb62
-rw-r--r--lib/arel/algebra/primitives/attribute.rb14
2 files changed, 39 insertions, 37 deletions
diff --git a/lib/arel/algebra/predicates.rb b/lib/arel/algebra/predicates.rb
index 72167c2b27..8a0b41fa18 100644
--- a/lib/arel/algebra/predicates.rb
+++ b/lib/arel/algebra/predicates.rb
@@ -1,41 +1,43 @@
module Arel
- class Predicate
- def or(other_predicate)
- Or.new(self, other_predicate)
- end
+ module Predicates
+ class Predicate
+ def or(other_predicate)
+ Or.new(self, other_predicate)
+ end
- def and(other_predicate)
- And.new(self, other_predicate)
+ def and(other_predicate)
+ And.new(self, other_predicate)
+ end
end
- end
- class Binary < Predicate
- attributes :operand1, :operand2
- deriving :initialize
+ class Binary < Predicate
+ attributes :operand1, :operand2
+ deriving :initialize
- def ==(other)
- self.class === other and
- @operand1 == other.operand1 and
- @operand2 == other.operand2
- end
+ def ==(other)
+ self.class === other and
+ @operand1 == other.operand1 and
+ @operand2 == other.operand2
+ end
- def bind(relation)
- self.class.new(operand1.find_correlate_in(relation), operand2.find_correlate_in(relation))
+ def bind(relation)
+ self.class.new(operand1.find_correlate_in(relation), operand2.find_correlate_in(relation))
+ end
end
- end
- class Equality < Binary
- def ==(other)
- Equality === other and
- ((operand1 == other.operand1 and operand2 == other.operand2) or
- (operand1 == other.operand2 and operand2 == other.operand1))
+ class Equality < Binary
+ def ==(other)
+ Equality === other and
+ ((operand1 == other.operand1 and operand2 == other.operand2) or
+ (operand1 == other.operand2 and operand2 == other.operand1))
+ end
end
- end
- class GreaterThanOrEqualTo < Binary; end
- class GreaterThan < Binary; end
- class LessThanOrEqualTo < Binary; end
- class LessThan < Binary; end
- class Match < Binary; end
- class In < Binary; end
+ class GreaterThanOrEqualTo < Binary; end
+ class GreaterThan < Binary; end
+ class LessThanOrEqualTo < Binary; end
+ class LessThan < Binary; end
+ class Match < Binary; end
+ class In < Binary; end
+ end
end
diff --git a/lib/arel/algebra/primitives/attribute.rb b/lib/arel/algebra/primitives/attribute.rb
index 44a2f41733..40a7d61a53 100644
--- a/lib/arel/algebra/primitives/attribute.rb
+++ b/lib/arel/algebra/primitives/attribute.rb
@@ -82,31 +82,31 @@ module Arel
module Predications
def eq(other)
- Equality.new(self, other)
+ Predicates::Equality.new(self, other)
end
def lt(other)
- LessThan.new(self, other)
+ Predicates::LessThan.new(self, other)
end
def lteq(other)
- LessThanOrEqualTo.new(self, other)
+ Predicates::LessThanOrEqualTo.new(self, other)
end
def gt(other)
- GreaterThan.new(self, other)
+ Predicates::GreaterThan.new(self, other)
end
def gteq(other)
- GreaterThanOrEqualTo.new(self, other)
+ Predicates::GreaterThanOrEqualTo.new(self, other)
end
def matches(regexp)
- Match.new(self, regexp)
+ Predicates::Match.new(self, regexp)
end
def in(array)
- In.new(self, array)
+ Predicates::In.new(self, array)
end
end
include Predications