Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #8783 from goshakkk/refactor-journey-routes

Refactor Journey::Routes
  • Loading branch information...
commit 4bfcae0b6723146aa18fec49b5311db9d3939044 2 parents 699bae6 + 2467ec8
@rafaelfranca rafaelfranca authored
Showing with 11 additions and 12 deletions.
  1. +11 −12 actionpack/lib/action_dispatch/journey/routes.rb
View
23 actionpack/lib/action_dispatch/journey/routes.rb
@@ -33,24 +33,23 @@ def clear
end
def partitioned_routes
- @partitioned_routes ||= routes.partition { |r|
- r.path.anchored && r.ast.grep(Nodes::Symbol).all? { |n| n.default_regexp? }
- }
+ @partitioned_routes ||= routes.partition do |r|
+ r.path.anchored && r.ast.grep(Nodes::Symbol).all?(&:default_regexp?)
+ end
end
def ast
- return @ast if @ast
- return if partitioned_routes.first.empty?
-
- asts = partitioned_routes.first.map { |r| r.ast }
- @ast = Nodes::Or.new(asts)
+ @ast ||= begin
+ asts = partitioned_routes.first.map(&:ast)
+ Nodes::Or.new(asts) unless asts.empty?
+ end
end
def simulator
- return @simulator if @simulator
-
- gtg = GTG::Builder.new(ast).transition_table
- @simulator = GTG::Simulator.new(gtg)
+ @simulator ||= begin
+ gtg = GTG::Builder.new(ast).transition_table
+ GTG::Simulator.new(gtg)
+ end
end
# Add a route to the routing table.
Please sign in to comment.
Something went wrong with that request. Please try again.