aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/arel/algebra/header.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/arel/algebra/header.rb b/lib/arel/algebra/header.rb
index 3b8aea3422..dc779d53c3 100644
--- a/lib/arel/algebra/header.rb
+++ b/lib/arel/algebra/header.rb
@@ -4,9 +4,7 @@ module Arel
def initialize(attrs = [])
@attributes = attrs.to_ary
- @names = Hash.new do |h,k|
- h[k] = @attributes.detect { |a| a.named?(k) }
- end
+ @names = {}
end
def each
@@ -55,7 +53,8 @@ module Arel
end
def find_by_name(name)
- @names[name.to_sym]
+ k = name.to_sym
+ @names[k] ||= @attributes.detect { |a| a.named?(k) }
end
def find_by_attribute(attr)