Class: Swaggard::Parsers::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/swaggard/parsers/routes.rb

Instance Method Summary collapse

Instance Method Details

#run(routes) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/swaggard/parsers/routes.rb', line 5

def run(routes)
  return {} unless routes

  parsed_routes = {}

  routes.each do |route|
    controller = route_controller(route)
    action = route_action(route)

    parsed_routes[controller] ||= {}
    parsed_routes[controller][action] = {
      verb:         route_verb(route),
      path:         route_path(route),
      path_params:  route_path_params(route)
    }
  end

  parsed_routes
end