mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Perf fix - Use an instance variable instead of a class_attribute. Thanks @josevalim and @jhawthorn for the prompting.
This commit is contained in:
parent
f44db45c87
commit
be99ae78c9
1 changed files with 4 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue