Permalink
Browse files

Merge pull request #8779 from goshakkk/refactor-route-ast

Refactor Route#ast to use or-equals and block, instead of return with a check
  • Loading branch information...
2 parents a46e5ff + c730bef commit 706fb0184dd51f74b792046c5d5f75ae1a9e917f @carlosantoniodasilva carlosantoniodasilva committed Jan 6, 2013
Showing with 4 additions and 5 deletions.
  1. +4 −5 actionpack/lib/action_dispatch/journey/route.rb
View
9 actionpack/lib/action_dispatch/journey/route.rb
@@ -30,11 +30,10 @@ def initialize(name, app, path, constraints, defaults = {})
end
def ast
- return @decorated_ast if @decorated_ast
-
- @decorated_ast = path.ast
- @decorated_ast.grep(Nodes::Terminal).each { |n| n.memo = self }
- @decorated_ast
+ @decorated_ast ||= begin
+ path.ast.grep(Nodes::Terminal).each { |n| n.memo = self }
+ path.ast
+ end
end
def requirements # :nodoc:

0 comments on commit 706fb01

Please sign in to comment.