aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-06-16 21:12:47 +0100
committerJon Leighton <j@jonathanleighton.com>2011-06-16 21:13:56 +0100
commitbe99ae78c9c4b52541297f0fb146701070041c02 (patch)
treebba5c91d1fd6947f7d27d4acf17ce4d45cfc45ba /activerecord
parentf44db45c87561dca3f29555132504a4cbf19857e (diff)
downloadrails-be99ae78c9c4b52541297f0fb146701070041c02.tar.gz
rails-be99ae78c9c4b52541297f0fb146701070041c02.tar.bz2
rails-be99ae78c9c4b52541297f0fb146701070041c02.zip
Perf fix - Use an instance variable instead of a class_attribute. Thanks @josevalim and @jhawthorn for the prompting.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/base.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 08cccf1da2..6a5d282973 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -428,10 +428,6 @@ module ActiveRecord #:nodoc:
class_attribute :default_scopes, :instance_writer => false
self.default_scopes = []
- # Boolean flag to prevent infinite recursion when evaluating default scopes
- class_attribute :apply_default_scope, :instance_writer => false
- self.apply_default_scope = true
-
# Returns a hash of all the attributes that have been specified for serialization as
# keys and their class restriction as values.
class_attribute :serialized_attributes
@@ -1265,11 +1261,11 @@ MSG
self.default_scopes = default_scopes + [scope]
end
- # The apply_default_scope flag is used to prevent an infinite recursion situation where
+ # The @ignore_default_scope flag is used to prevent an infinite recursion situation where
# a default scope references a scope which has a default scope which references a scope...
def build_default_scope #:nodoc:
- return unless apply_default_scope
- self.apply_default_scope = false
+ return if defined?(@ignore_default_scope) && @ignore_default_scope
+ @ignore_default_scope = true
if method(:default_scope).owner != Base.singleton_class
default_scope
@@ -1285,7 +1281,7 @@ MSG
end
end
ensure
- self.apply_default_scope = true
+ @ignore_default_scope = false
end
# Returns the class type of the record using the current module as a prefix. So descendants of