Class: Trains::Visitor::Route
- Includes:
- Utils::Args
- Defined in:
- lib/trains/visitor/route.rb
Overview
Visitor for Parsing Rails routes
Constant Summary collapse
- ALLOWED_VERBS =
%i[get put post update delete resources].freeze
Instance Method Summary collapse
-
#initialize ⇒ Route
constructor
A new instance of Route.
- #on_block(node) ⇒ Object
- #result ⇒ Object
Methods included from Utils::Args
#parse_args, #parse_hash, #parse_value
Constructor Details
#initialize ⇒ Route
Returns a new instance of Route.
21 22 23 |
# File 'lib/trains/visitor/route.rb', line 21 def initialize @route_list = [] end |
Instance Method Details
#on_block(node) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/trains/visitor/route.rb', line 29 def on_block(node) return unless route_parent?(node) node.each_descendant(:send) do |child| ALLOWED_VERBS.each do |verb| if route_method?(child, verb) @route_list << parse_route(child, verb) end end end end |
#result ⇒ Object
25 26 27 |
# File 'lib/trains/visitor/route.rb', line 25 def result @route_list end |