mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
avoid is_a? checks
add another predicate method so we can avoid is_a checks
This commit is contained in:
parent
56f734a361
commit
8d7b883f33
2 changed files with 4 additions and 2 deletions
|
@ -40,6 +40,7 @@ module ActionDispatch
|
|||
def symbol?; false; end
|
||||
def literal?; false; end
|
||||
def terminal?; false; end
|
||||
def star?; false; end
|
||||
end
|
||||
|
||||
class Terminal < Node # :nodoc:
|
||||
|
@ -94,6 +95,7 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
class Star < Unary # :nodoc:
|
||||
def star?; true; end
|
||||
def type; :STAR; end
|
||||
|
||||
def name
|
||||
|
|
|
@ -32,12 +32,12 @@ module ActionDispatch
|
|||
end
|
||||
|
||||
def ast
|
||||
@spec.grep(Nodes::Symbol).each do |node|
|
||||
@spec.find_all(&:symbol?).each do |node|
|
||||
re = @requirements[node.to_sym]
|
||||
node.regexp = re if re
|
||||
end
|
||||
|
||||
@spec.grep(Nodes::Star).each do |node|
|
||||
@spec.find_all(&:star?).each do |node|
|
||||
node = node.left
|
||||
node.regexp = @requirements[node.to_sym] || /(.+)/
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue