mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
add a null node at the top of the stack
this gives us an easier way to iterate the stack
This commit is contained in:
parent
53454bfcb6
commit
8e014f28cc
1 changed files with 9 additions and 13 deletions
|
@ -1702,9 +1702,9 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
def shallow_nesting_depth #:nodoc:
|
def shallow_nesting_depth #:nodoc:
|
||||||
@scope.find_all { |frame|
|
@scope.find_all { |node|
|
||||||
frame[:scope_level_resource]
|
node.frame[:scope_level_resource]
|
||||||
}.count { |frame| frame[:scope_level_resource].shallow? }
|
}.count { |node| node.frame[:scope_level_resource].shallow? }
|
||||||
end
|
end
|
||||||
|
|
||||||
def param_constraint? #:nodoc:
|
def param_constraint? #:nodoc:
|
||||||
|
@ -1974,16 +1974,14 @@ module ActionDispatch
|
||||||
self.class.new hash, self, scope_level
|
self.class.new hash, self, scope_level
|
||||||
end
|
end
|
||||||
|
|
||||||
|
EMPTY_HASH = {}.freeze
|
||||||
def new_level(level)
|
def new_level(level)
|
||||||
self.class.new(self, self, level)
|
self.class.new(EMPTY_HASH, self, level)
|
||||||
end
|
|
||||||
|
|
||||||
def fetch(key, &block)
|
|
||||||
@hash.fetch(key, &block)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](key)
|
def [](key)
|
||||||
@hash.fetch(key) { @parent[key] }
|
scope = find { |node| node.frame.key? key }
|
||||||
|
scope && scope.frame[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
include Enumerable
|
include Enumerable
|
||||||
|
@ -1992,16 +1990,14 @@ module ActionDispatch
|
||||||
node = self
|
node = self
|
||||||
loop do
|
loop do
|
||||||
break if node.equal? NULL
|
break if node.equal? NULL
|
||||||
yield node.frame
|
yield node
|
||||||
node = node.parent
|
node = node.parent
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def frame; @hash; end
|
def frame; @hash; end
|
||||||
|
|
||||||
NULL = Scope.new({}.freeze, {}.freeze)
|
NULL = Scope.new(nil, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(set) #:nodoc:
|
def initialize(set) #:nodoc:
|
||||||
|
|
Loading…
Reference in a new issue