提交 919e7d3e 编写于 作者: A Aaron Patterson

push `scope` calls up one frame

eliminates calling `scope` in one method, pushes the other calls up one
frame.  This goes a little way towards eliminating the internal calls to
`scope`.
上级 644c4efd
......@@ -1421,7 +1421,9 @@ def member
with_scope_level(:member) do
if shallow?
shallow_scope(parent_resource.member_scope) { yield }
shallow_scope {
path_scope(parent_resource.member_scope) { yield }
}
else
path_scope(parent_resource.member_scope) { yield }
end
......@@ -1447,9 +1449,15 @@ def nested
with_scope_level(:nested) do
if shallow? && shallow_nesting_depth >= 1
shallow_scope(parent_resource.nested_scope, nested_options) { yield }
shallow_scope do
path_scope(parent_resource.nested_scope) do
scope(nested_options) { yield }
end
end
else
scope(parent_resource.nested_scope, nested_options) { yield }
path_scope(parent_resource.nested_scope) do
scope(nested_options) { yield }
end
end
end
end
......@@ -1720,12 +1728,12 @@ def canonical_action?(action) #:nodoc:
resource_method_scope? && CANONICAL_ACTIONS.include?(action.to_s)
end
def shallow_scope(path, options = {}) #:nodoc:
def shallow_scope #:nodoc:
scope = { :as => @scope[:shallow_prefix],
:path => @scope[:shallow_path] }
@scope = @scope.new scope
scope(path, options) { yield }
yield
ensure
@scope = @scope.parent
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册