mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
use predicate methods to avoid is_a? checks
we may want to change the name of the class at some point, so it's better to use a predicate
This commit is contained in:
parent
e9777ef62e
commit
d12ff4fa50
2 changed files with 3 additions and 1 deletions
|
@ -39,10 +39,12 @@ module ActionDispatch
|
|||
|
||||
def symbol?; false; end
|
||||
def literal?; false; end
|
||||
def terminal?; false; end
|
||||
end
|
||||
|
||||
class Terminal < Node # :nodoc:
|
||||
alias :symbol :left
|
||||
def terminal?; true; end
|
||||
end
|
||||
|
||||
class Literal < Terminal # :nodoc:
|
||||
|
|
|
@ -30,7 +30,7 @@ module ActionDispatch
|
|||
def ast
|
||||
@decorated_ast ||= begin
|
||||
decorated_ast = path.ast
|
||||
decorated_ast.grep(Nodes::Terminal).each { |n| n.memo = self }
|
||||
decorated_ast.find_all(&:terminal?).each { |n| n.memo = self }
|
||||
decorated_ast
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue