aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-01-06 14:30:35 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-01-06 14:30:35 -0800
commit4bfcae0b6723146aa18fec49b5311db9d3939044 (patch)
tree58fe3fb4f03c2bb65974ddc45fe6cae1bed28033
parent699bae691f3b692be3d93d75fde955fc4d23dd09 (diff)
parent2467ec8b5ce1be8481283943e830c56d0c827040 (diff)
downloadrails-4bfcae0b6723146aa18fec49b5311db9d3939044.tar.gz
rails-4bfcae0b6723146aa18fec49b5311db9d3939044.tar.bz2
rails-4bfcae0b6723146aa18fec49b5311db9d3939044.zip
Merge pull request #8783 from goshakkk/refactor-journey-routes
Refactor Journey::Routes
-rw-r--r--actionpack/lib/action_dispatch/journey/routes.rb23
1 files changed, 11 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/journey/routes.rb b/actionpack/lib/action_dispatch/journey/routes.rb
index 32829a1f20..9d59c9265e 100644
--- a/actionpack/lib/action_dispatch/journey/routes.rb
+++ b/actionpack/lib/action_dispatch/journey/routes.rb
@@ -33,24 +33,23 @@ module ActionDispatch
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.