aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-25 17:23:25 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-25 17:23:25 -0700
commit3ae0cdf21980e454b1fdaf6005179080c0114c27 (patch)
tree423858d93efce0d0bfc50e9f68dc994903ed13c2 /lib/arel/algebra/relations
parentb1a55238f3ac510b535490e8ccdef65dfc351ecf (diff)
downloadrails-3ae0cdf21980e454b1fdaf6005179080c0114c27.tar.gz
rails-3ae0cdf21980e454b1fdaf6005179080c0114c27.tar.bz2
rails-3ae0cdf21980e454b1fdaf6005179080c0114c27.zip
removing more metaprogramming
Diffstat (limited to 'lib/arel/algebra/relations')
-rw-r--r--lib/arel/algebra/relations/operations/having.rb11
-rw-r--r--lib/arel/algebra/relations/operations/join.rb26
2 files changed, 26 insertions, 11 deletions
diff --git a/lib/arel/algebra/relations/operations/having.rb b/lib/arel/algebra/relations/operations/having.rb
index daca1f7bce..fdd35626af 100644
--- a/lib/arel/algebra/relations/operations/having.rb
+++ b/lib/arel/algebra/relations/operations/having.rb
@@ -1,16 +1,21 @@
module Arel
class Having < Compound
- attributes :relation, :predicates
- deriving :==
+ attr_reader :predicates
def initialize(relation, *predicates)
+ super(relation)
predicates = [yield(relation)] + predicates if block_given?
@predicates = predicates.map { |p| p.bind(relation) }
- @relation = relation
end
def havings
@havings ||= relation.havings + predicates
end
+
+ def == other
+ super || Having === other &&
+ relation == other.relation &&
+ predicates == other.predicates
+ end
end
end
diff --git a/lib/arel/algebra/relations/operations/join.rb b/lib/arel/algebra/relations/operations/join.rb
index 21bcfaa62d..dd67e8a9bf 100644
--- a/lib/arel/algebra/relations/operations/join.rb
+++ b/lib/arel/algebra/relations/operations/join.rb
@@ -2,20 +2,20 @@ module Arel
class Join
include Relation
- attributes :relation1, :relation2, :predicates
- deriving :==
- delegate :name, :to => :relation1
+ attr_reader :relation1, :relation2, :predicates
def initialize(relation1, relation2 = Nil.instance, *predicates)
- @relation1, @relation2, @predicates = relation1, relation2, predicates
+ @relation1 = relation1
+ @relation2 = relation2
+ @predicates = predicates
end
- def hash
- @hash ||= :relation1.hash
+ def name
+ relation1.name
end
- def eql?(other)
- self == other
+ def hash
+ @hash ||= :relation1.hash
end
def attributes
@@ -43,6 +43,16 @@ module Arel
def engine
relation1.engine != relation2.engine ? Memory::Engine.new : relation1.engine
end
+
+ def == other
+ super || Join === other &&
+ relation1 == other.relation1 &&
+ relation2 == other.relation2 &&
+ predicates == other.predicates
+ end
+
+ # FIXME remove this. :'(
+ alias :eql? :==
end
class InnerJoin < Join; end