aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-08-17 13:36:09 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-08-17 13:51:39 -0700
commitd12ff4fa50719e5282cb2a357968b9532ddce683 (patch)
tree6f86891ba91fd905b6be60b1bf24045edd7bb735
parente9777ef62e95be79fee01fea9e7420726d5ff792 (diff)
downloadrails-d12ff4fa50719e5282cb2a357968b9532ddce683.tar.gz
rails-d12ff4fa50719e5282cb2a357968b9532ddce683.tar.bz2
rails-d12ff4fa50719e5282cb2a357968b9532ddce683.zip
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
-rw-r--r--actionpack/lib/action_dispatch/journey/nodes/node.rb2
-rw-r--r--actionpack/lib/action_dispatch/journey/route.rb2
2 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/journey/nodes/node.rb b/actionpack/lib/action_dispatch/journey/nodes/node.rb
index cf6542b370..a2de6ce1c8 100644
--- a/actionpack/lib/action_dispatch/journey/nodes/node.rb
+++ b/actionpack/lib/action_dispatch/journey/nodes/node.rb
@@ -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:
diff --git a/actionpack/lib/action_dispatch/journey/route.rb b/actionpack/lib/action_dispatch/journey/route.rb
index 1ead6c8a82..7fcb4080e8 100644
--- a/actionpack/lib/action_dispatch/journey/route.rb
+++ b/actionpack/lib/action_dispatch/journey/route.rb
@@ -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