提交 6bc8ada0 编写于 作者: A Aaron Patterson

push `with_scope_level` up so resource_scope doesn't know

`resource_scope` should just put resource scopes on the stack, and
doesn't need to know what a `scope_level` is.
上级 d4e1a759
......@@ -1197,20 +1197,22 @@ def resource(*resources, &block)
return self
end
resource_scope(:resource, SingletonResource.new(resources.pop, api_only?, @scope[:shallow], options)) do
yield if block_given?
with_scope_level(:resource) do
resource_scope(SingletonResource.new(resources.pop, api_only?, @scope[:shallow], options)) do
yield if block_given?
concerns(options[:concerns]) if options[:concerns]
concerns(options[:concerns]) if options[:concerns]
collection do
post :create
end if parent_resource.actions.include?(:create)
collection do
post :create
end if parent_resource.actions.include?(:create)
new do
get :new
end if parent_resource.actions.include?(:new)
new do
get :new
end if parent_resource.actions.include?(:new)
set_member_mappings_for_resource
set_member_mappings_for_resource
end
end
self
......@@ -1355,21 +1357,23 @@ def resources(*resources, &block)
return self
end
resource_scope(:resources, Resource.new(resources.pop, api_only?, @scope[:shallow], options)) do
yield if block_given?
with_scope_level(:resources) do
resource_scope(Resource.new(resources.pop, api_only?, @scope[:shallow], options)) do
yield if block_given?
concerns(options[:concerns]) if options[:concerns]
concerns(options[:concerns]) if options[:concerns]
collection do
get :index if parent_resource.actions.include?(:index)
post :create if parent_resource.actions.include?(:create)
end
collection do
get :index if parent_resource.actions.include?(:index)
post :create if parent_resource.actions.include?(:create)
end
new do
get :new
end if parent_resource.actions.include?(:new)
new do
get :new
end if parent_resource.actions.include?(:new)
set_member_mappings_for_resource
set_member_mappings_for_resource
end
end
self
......@@ -1682,12 +1686,10 @@ def with_scope_level(kind)
@scope = @scope.parent
end
def resource_scope(kind, resource) #:nodoc:
def resource_scope(resource) #:nodoc:
@scope = @scope.new(:scope_level_resource => resource)
with_scope_level(kind) do
controller_scope(resource.resource_scope) { yield }
end
controller_scope(resource.resource_scope) { yield }
ensure
@scope = @scope.parent
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册