aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2014-03-02 14:02:25 +0200
committerAndrew White <andyw@pixeltrix.co.uk>2014-03-08 19:51:06 +0000
commited0fb4ae7ea28cf3eecce6ec02650bcffc7c7657 (patch)
tree51ce52cef30a56a4a555204117cd4d410f6209b4 /actionpack
parent002c0634d1e11a13e901288c66219808aff51f83 (diff)
downloadrails-ed0fb4ae7ea28cf3eecce6ec02650bcffc7c7657.tar.gz
rails-ed0fb4ae7ea28cf3eecce6ec02650bcffc7c7657.tar.bz2
rails-ed0fb4ae7ea28cf3eecce6ec02650bcffc7c7657.zip
Move setting :scope_level_resource to resource_scope
Originally with_scope_level was exclusively for managing scope levels with resources, however it is now used for other things so it makes more sense to move the responsibility for setting the :scope_level_resource to the resource_scope method. This eliminates repeatedly setting it to the same resource as each resource method scope is evaluated.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 0b762aa9a4..5da6582b15 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1558,21 +1558,21 @@ module ActionDispatch
end
end
- def with_scope_level(kind, resource = parent_resource)
+ def with_scope_level(kind)
old, @scope[:scope_level] = @scope[:scope_level], kind
- old_resource, @scope[:scope_level_resource] = @scope[:scope_level_resource], resource
yield
ensure
@scope[:scope_level] = old
- @scope[:scope_level_resource] = old_resource
end
def resource_scope(kind, resource) #:nodoc:
- with_scope_level(kind, resource) do
- scope(parent_resource.resource_scope) do
- yield
- end
+ old_resource, @scope[:scope_level_resource] = @scope[:scope_level_resource], resource
+
+ with_scope_level(kind) do
+ scope(parent_resource.resource_scope) { yield }
end
+ ensure
+ @scope[:scope_level_resource] = old_resource
end
def nested_options #:nodoc: