aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/scoping
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-09-11 21:41:11 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-09-11 21:41:11 +0900
commit517a54501d2de1225327296adde8efb91774b237 (patch)
treea4c4809d11acba2f87af5ed29c62fe470659765a /activerecord/lib/active_record/scoping
parent4895e5cfc753a7145b02edeb48a80824dda57cba (diff)
downloadrails-517a54501d2de1225327296adde8efb91774b237.tar.gz
rails-517a54501d2de1225327296adde8efb91774b237.tar.bz2
rails-517a54501d2de1225327296adde8efb91774b237.zip
Don't expose `current_scope` for internal use
Diffstat (limited to 'activerecord/lib/active_record/scoping')
-rw-r--r--activerecord/lib/active_record/scoping/named.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 23e84ad1de..573d97b819 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -24,13 +24,13 @@ module ActiveRecord
# You can define a scope that applies to all finders using
# {default_scope}[rdoc-ref:Scoping::Default::ClassMethods#default_scope].
def all
- current_scope = self.current_scope
+ scope = current_scope
- if current_scope
- if self == current_scope.klass
- current_scope.clone
+ if scope
+ if self == scope.klass
+ scope.clone
else
- relation.merge!(current_scope)
+ relation.merge!(scope)
end
else
default_scoped
@@ -38,9 +38,7 @@ module ActiveRecord
end
def scope_for_association(scope = relation) # :nodoc:
- current_scope = self.current_scope
-
- if current_scope && current_scope.empty_scope?
+ if current_scope&.empty_scope?
scope
else
default_scoped(scope)