From 19c5a95f1093653d2628dfb2f53637b0425dbba4 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 30 Jul 2010 14:41:26 -0700 Subject: caching existence of a table --- lib/arel/engines/sql/relations/table.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/arel/engines/sql/relations/table.rb b/lib/arel/engines/sql/relations/table.rb index f56fd7d813..8266897098 100644 --- a/lib/arel/engines/sql/relations/table.rb +++ b/lib/arel/engines/sql/relations/table.rb @@ -13,6 +13,8 @@ module Arel end attr_reader :name, :engine, :table_alias, :options, :christener + attr_reader :table_exists + alias :table_exists? :table_exists def initialize(name, options = {}) @name = name.to_s @@ -45,6 +47,8 @@ module Arel end @@tables ||= engine.connection.tables + @table_exists = @@tables.include?(name) || + @engine.connection.table_exists?(name) end end @@ -52,10 +56,6 @@ module Arel Table.new(name, options.merge(:as => table_alias)) end - def table_exists? - @table_exists ||= @@tables.include?(name) || engine.connection.table_exists?(name) - end - def attributes return @attributes if defined?(@attributes) if table_exists? -- cgit v1.2.3