提交 53454bfc 编写于 作者: A Aaron Patterson

remove `@nesting` ivar

The same information is stored in the `@scope` linked list, so just get
it from there.
上级 d9603cb0
......@@ -1684,13 +1684,11 @@ def with_scope_level(kind)
def resource_scope(kind, resource) #:nodoc:
@scope = @scope.new(:scope_level_resource => resource)
@nesting.push(resource)
with_scope_level(kind) do
controller_scope(resource.resource_scope) { yield }
end
ensure
@nesting.pop
@scope = @scope.parent
end
......@@ -1703,12 +1701,10 @@ def nested_options #:nodoc:
options
end
def nesting_depth #:nodoc:
@nesting.size
end
def shallow_nesting_depth #:nodoc:
@nesting.count(&:shallow?)
@scope.find_all { |frame|
frame[:scope_level_resource]
}.count { |frame| frame[:scope_level_resource].shallow? }
end
def param_constraint? #:nodoc:
......@@ -1931,7 +1927,7 @@ class Scope # :nodoc:
attr_reader :parent, :scope_level
def initialize(hash, parent = {}, scope_level = nil)
def initialize(hash, parent = NULL, scope_level = nil)
@hash = hash
@parent = parent
@scope_level = scope_level
......@@ -1989,13 +1985,29 @@ def fetch(key, &block)
def [](key)
@hash.fetch(key) { @parent[key] }
end
include Enumerable
def each
node = self
loop do
break if node.equal? NULL
yield node.frame
node = node.parent
end
end
protected
def frame; @hash; end
NULL = Scope.new({}.freeze, {}.freeze)
end
def initialize(set) #:nodoc:
@set = set
@scope = Scope.new({ :path_names => @set.resources_path_names })
@concerns = {}
@nesting = []
end
include Base
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册