mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
refactor Journey::Routes
* prefer do-end for multiline blocks * prefer or-equals over returns with checks
This commit is contained in:
parent
807e176aba
commit
2467ec8b5c
1 changed files with 11 additions and 12 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue