Skip to content

Commit 6411dbb

Browse files
authored
Merge pull request rails#54675 from skipkayhil/hm-lazy-visualizer
Fix creating fsm visualizer with lazy routes
2 parents d757881 + 66c67c8 commit 6411dbb

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

actionpack/lib/action_dispatch/journey/router.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,7 @@ def recognize(req, &block)
9898
end
9999
end
100100

101-
def visualizer
102-
tt = GTG::Builder.new(ast).transition_table
103-
groups = partitioned_routes.first.map(&:ast).group_by(&:to_s)
104-
asts = groups.values.map(&:first)
105-
tt.visualizer(asts)
106-
end
107-
108101
private
109-
def partitioned_routes
110-
routes.partition { |r|
111-
r.path.anchored && r.path.requirements_anchored?
112-
}
113-
end
114-
115-
def ast
116-
routes.ast
117-
end
118-
119102
def simulator
120103
routes.simulator
121104
end
@@ -125,7 +108,6 @@ def custom_routes
125108
end
126109

127110
def filter_routes(path)
128-
return [] unless ast
129111
simulator.memos(path) { [] }
130112
end
131113

actionpack/lib/action_dispatch/journey/routes.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ def add_route(name, mapping)
7272
route
7373
end
7474

75+
def visualizer
76+
tt = GTG::Builder.new(ast).transition_table
77+
groups = anchored_routes.map(&:ast).group_by(&:to_s)
78+
asts = groups.values.map(&:first)
79+
tt.visualizer(asts)
80+
end
81+
7582
private
7683
def clear_cache!
7784
@ast = nil

0 commit comments

Comments
 (0)