aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2009-05-18 01:25:09 -0400
committerBryan Helmkamp <bryan@brynary.com>2009-05-18 01:25:09 -0400
commit65e419c172217f9747e2e56b36fcc4b6089a0d6d (patch)
treee68865661fba3eef0731c9885d3c3ba5fe45944c /lib
parent930c9f90a03729bdc380ab84882a118d8c17e54d (diff)
downloadrails-65e419c172217f9747e2e56b36fcc4b6089a0d6d.tar.gz
rails-65e419c172217f9747e2e56b36fcc4b6089a0d6d.tar.bz2
rails-65e419c172217f9747e2e56b36fcc4b6089a0d6d.zip
Expand usages of #hash_on. The #hash definition it produces looks broken, but leaving it for now
Diffstat (limited to 'lib')
-rw-r--r--lib/arel/algebra/extensions/class.rb10
-rw-r--r--lib/arel/algebra/relations/operations/join.rb9
-rw-r--r--lib/arel/algebra/relations/utilities/compound.rb12
-rw-r--r--lib/arel/engines/sql/relations/table.rb9
4 files changed, 26 insertions, 14 deletions
diff --git a/lib/arel/algebra/extensions/class.rb b/lib/arel/algebra/extensions/class.rb
index d005814f91..520111b90f 100644
--- a/lib/arel/algebra/extensions/class.rb
+++ b/lib/arel/algebra/extensions/class.rb
@@ -25,16 +25,6 @@ module Arel
}
class_eval methods[method_name], __FILE__, __LINE__
end
-
- def hash_on(delegatee)
- define_method :eql? do |other|
- self == other
- end
-
- define_method :hash do
- @hash ||= delegatee.hash
- end
- end
Class.send(:include, self)
end
diff --git a/lib/arel/algebra/relations/operations/join.rb b/lib/arel/algebra/relations/operations/join.rb
index e47d9fa9e0..e9320f28e1 100644
--- a/lib/arel/algebra/relations/operations/join.rb
+++ b/lib/arel/algebra/relations/operations/join.rb
@@ -3,12 +3,19 @@ module Arel
attributes :relation1, :relation2, :predicates
deriving :==
delegate :name, :to => :relation1
- hash_on :relation1
def initialize(relation1, relation2 = Nil.instance, *predicates)
@relation1, @relation2, @predicates = relation1, relation2, predicates
end
+ def hash
+ @hash ||= :relation1.hash
+ end
+
+ def eql?(other)
+ self == other
+ end
+
def attributes
@attributes ||= (relation1.externalize.attributes +
relation2.externalize.attributes).collect { |a| a.bind(self) }
diff --git a/lib/arel/algebra/relations/utilities/compound.rb b/lib/arel/algebra/relations/utilities/compound.rb
index 676d80a737..5e775618f1 100644
--- a/lib/arel/algebra/relations/utilities/compound.rb
+++ b/lib/arel/algebra/relations/utilities/compound.rb
@@ -1,7 +1,6 @@
module Arel
class Compound < Relation
attr_reader :relation
- hash_on :relation
delegate :joins, :join?, :inserts, :taken, :skipped, :name, :externalizable?,
:column_for, :engine,
:to => :relation
@@ -14,7 +13,16 @@ module Arel
OPERATION
end
- private
+ def hash
+ @hash ||= :relation.hash
+ end
+
+ def eql?(other)
+ self == other
+ end
+
+ private
+
def arguments_from_block(relation, &block)
block_given?? [yield(relation)] : []
end
diff --git a/lib/arel/engines/sql/relations/table.rb b/lib/arel/engines/sql/relations/table.rb
index 0b6574eedc..dd22f44226 100644
--- a/lib/arel/engines/sql/relations/table.rb
+++ b/lib/arel/engines/sql/relations/table.rb
@@ -4,7 +4,6 @@ module Arel
cattr_accessor :engine
attr_reader :name, :engine
- hash_on :name
def initialize(name, engine = Table.engine)
@name, @engine = name.to_s, engine
@@ -16,6 +15,14 @@ module Arel
end
end
+ def eql?(other)
+ self == other
+ end
+
+ def hash
+ @hash ||= :name.hash
+ end
+
def format(attribute, value)
attribute.column.type_cast(value)
end