From 0d6997b6e3f25d87b08b4aacaa2140609d5cc19c Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Tue, 18 Aug 2009 14:49:11 -0300 Subject: Cache #arel_able when possible. --- activerecord/lib/active_record/base.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index b23ce53d43..3bbe23865f 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1533,9 +1533,12 @@ module ActiveRecord #:nodoc: end - def arel_table(table = nil) + def arel_table(table = nil, reload = nil) table = table_name if table.blank? - Relation.new(self, Arel::Table.new(table)) + if reload || @arel_table.nil? || @arel_table.name != table + @arel_table = Relation.new(self, Arel::Table.new(table)) + end + @arel_table end private -- cgit v1.2.3