aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-28 14:16:09 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-28 14:55:00 -0700
commit635f11d7fb8e7382314f5484d924b755a1e91be6 (patch)
tree3a438510d245ba02d15cac56e170736f711f47ac /lib/arel
parente26006fb877f8b9e75d814f3499c7e3dd7dc47b7 (diff)
downloadrails-635f11d7fb8e7382314f5484d924b755a1e91be6.tar.gz
rails-635f11d7fb8e7382314f5484d924b755a1e91be6.tar.bz2
rails-635f11d7fb8e7382314f5484d924b755a1e91be6.zip
no need for a lambda
Diffstat (limited to 'lib/arel')
-rw-r--r--lib/arel/algebra/attributes/attribute.rb4
-rw-r--r--lib/arel/algebra/relations/relation.rb8
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/arel/algebra/attributes/attribute.rb b/lib/arel/algebra/attributes/attribute.rb
index 50d79fa4b9..13781f47e0 100644
--- a/lib/arel/algebra/attributes/attribute.rb
+++ b/lib/arel/algebra/attributes/attribute.rb
@@ -29,6 +29,8 @@ module Arel
@ancestor == other.ancestor
end
+ alias :eql? :==
+
def named?(hypothetical_name)
(@alias || name).to_s == hypothetical_name.to_s
end
@@ -41,8 +43,6 @@ module Arel
row[self]
end
- alias :eql? :==
-
def hash
@hash ||= name.hash + root.relation.hash
end
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb
index 9cb38218c0..62d9bf177c 100644
--- a/lib/arel/algebra/relations/relation.rb
+++ b/lib/arel/algebra/relations/relation.rb
@@ -187,9 +187,11 @@ module Arel
end
def position_of(attribute)
- (@position_of ||= Hash.new do |h, attribute|
- h[attribute] = attributes.index(self[attribute])
- end)[attribute]
+ @position_of ||= {}
+
+ return @position_of[attribute] if @position_of.key? attribute
+
+ @position_of[attribute] = attributes.index(attributes[attribute])
end
private