From c7b4f12d9339504b58431de0145d9a965008e650 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 6 Aug 2010 14:57:54 -0700 Subject: removing parameter requirement for matching_attributes --- lib/arel/algebra/relations/relation.rb | 14 -------------- lib/arel/engines/sql/relations/table.rb | 9 +++++++++ 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'lib/arel') diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb index 4c739edb4d..9807cfb984 100644 --- a/lib/arel/algebra/relations/relation.rb +++ b/lib/arel/algebra/relations/relation.rb @@ -197,19 +197,5 @@ module Arel def skipped; nil end def sources; [] end def locked; [] end - - private - def matching_attributes(attribute) - unless @matching_attributes - @matching_attributes = Hash[attributes.map do |a| - [a.root, a] - end] - end - [@matching_attributes[attribute.root]] || [] - end - - def has_attribute?(attribute) - !matching_attributes(attribute).empty? - end end end diff --git a/lib/arel/engines/sql/relations/table.rb b/lib/arel/engines/sql/relations/table.rb index dd9000d660..b31df7a6d0 100644 --- a/lib/arel/engines/sql/relations/table.rb +++ b/lib/arel/engines/sql/relations/table.rb @@ -82,6 +82,15 @@ module Arel @columns = nil @attributes = Header.new([]) end + + private + def matching_attributes + @matching_attributes ||= Hash[attributes.map { |a| [a.root, true] }] + end + + def has_attribute?(attribute) + matching_attributes.key? attribute.root + end end end -- cgit v1.2.3