From ed0fb4ae7ea28cf3eecce6ec02650bcffc7c7657 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Sun, 2 Mar 2014 14:02:25 +0200 Subject: 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. --- actionpack/lib/action_dispatch/routing/mapper.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'actionpack') 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: -- cgit v1.2.3