aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/scoping
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-02-07 19:40:10 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-02-07 19:44:25 +0900
commit2e018361c7c51e36d1d98bf770b7456d78dee68b (patch)
treea0f15f942a5b18e3c692965ac345f9f4010bb668 /activerecord/lib/active_record/scoping
parent973b62dcddd2db45047d32321e6887c841fc5ccf (diff)
downloadrails-2e018361c7c51e36d1d98bf770b7456d78dee68b.tar.gz
rails-2e018361c7c51e36d1d98bf770b7456d78dee68b.tar.bz2
rails-2e018361c7c51e36d1d98bf770b7456d78dee68b.zip
Refactor around scoping
Don't use `false` as special value to skip to find inherited scope, we could use `skip_inherited_scope = true`, and move `_scoping` back on Relation.
Diffstat (limited to 'activerecord/lib/active_record/scoping')
-rw-r--r--activerecord/lib/active_record/scoping/default.rb9
-rw-r--r--activerecord/lib/active_record/scoping/named.rb3
2 files changed, 2 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb
index 6caf9b3251..8c612df27a 100644
--- a/activerecord/lib/active_record/scoping/default.rb
+++ b/activerecord/lib/active_record/scoping/default.rb
@@ -31,14 +31,7 @@ module ActiveRecord
# Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10"
# }
def unscoped
- block_given? ? _scoping(relation) { yield } : relation
- end
-
- def _scoping(relation) # :nodoc:
- previous, self.current_scope = current_scope(true), relation
- yield
- ensure
- self.current_scope = previous
+ block_given? ? relation.scoping { yield } : relation
end
# Are there attributes associated with this scope?
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 987e6bd63f..5278eb29a9 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -180,8 +180,7 @@ module ActiveRecord
if body.respond_to?(:to_proc)
singleton_class.define_method(name) do |*args|
- scope = all
- scope = _scoping(false) { scope._exec_scope(*args, &body) }
+ scope = all._exec_scope(*args, &body)
scope = scope.extending(extension) if extension
scope
end