Permalink
Browse files

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.
  • Loading branch information...
1 parent 002c063 commit ed0fb4ae7ea28cf3eecce6ec02650bcffc7c7657 @pixeltrix pixeltrix committed Mar 2, 2014
Showing with 7 additions and 7 deletions.
  1. +7 −7 actionpack/lib/action_dispatch/routing/mapper.rb
View
14 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1558,21 +1558,21 @@ def with_exclusive_scope
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:

0 comments on commit ed0fb4a

Please sign in to comment.