aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/mapper.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-08 18:48:27 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-08 18:48:27 -0700
commitf360689586814c8e81f050e13b88bfd978ae69eb (patch)
treeea5dbf513a50ddd2e13718c89b34c623ff5900fc /actionpack/lib/action_dispatch/routing/mapper.rb
parent5a18b853ed9b04cf7d610390fab7de13cc23108e (diff)
downloadrails-f360689586814c8e81f050e13b88bfd978ae69eb.tar.gz
rails-f360689586814c8e81f050e13b88bfd978ae69eb.tar.bz2
rails-f360689586814c8e81f050e13b88bfd978ae69eb.zip
stop calling `scope` internally
we need to get a grip on what `scope` actually does. This commit removes some of the internal calls to `scope`. Eventually we should add public facing methods that provide the API that `scope` is trying to accomplish.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb30
1 files changed, 23 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index d5f641a88a..52519188a9 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1397,7 +1397,7 @@ module ActionDispatch
end
with_scope_level(:collection) do
- scope(parent_resource.collection_scope) do
+ path_scope(parent_resource.collection_scope) do
yield
end
end
@@ -1423,7 +1423,7 @@ module ActionDispatch
if shallow?
shallow_scope(parent_resource.member_scope) { yield }
else
- scope(parent_resource.member_scope) { yield }
+ path_scope(parent_resource.member_scope) { yield }
end
end
end
@@ -1434,7 +1434,7 @@ module ActionDispatch
end
with_scope_level(:new) do
- scope(parent_resource.new_scope(action_path(:new))) do
+ path_scope(parent_resource.new_scope(action_path(:new))) do
yield
end
end
@@ -1464,9 +1464,10 @@ module ActionDispatch
end
def shallow
- scope(:shallow => true) do
- yield
- end
+ @scope = @scope.new(shallow: true)
+ yield
+ ensure
+ @scope = @scope.parent
end
def shallow?
@@ -1683,7 +1684,7 @@ module ActionDispatch
@nesting.push(resource)
with_scope_level(kind) do
- scope(parent_resource.resource_scope) { yield }
+ controller_scope(parent_resource.resource_scope[:controller]) { yield }
end
ensure
@nesting.pop
@@ -1795,6 +1796,21 @@ module ActionDispatch
def api_only?
@set.api_only?
end
+ private
+
+ def controller_scope(controller)
+ @scope = @scope.new(controller: controller)
+ yield
+ ensure
+ @scope = @scope.parent
+ end
+
+ def path_scope(path)
+ @scope = @scope.new(path: merge_path_scope(@scope[:path], path))
+ yield
+ ensure
+ @scope = @scope.parent
+ end
end
# Routing Concerns allow you to declare common routes that can be reused