Class: Chusaku::Routes

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

Overview

Handles extracting information about the Rails project's routes.

Class Method Summary collapse

Class Method Details

.callHash

Primary method to call.

Example output:

{
"users" => {
  "edit" => [
    {
      verb: "GET",
      path: "/users/:id",
      name: "edit_user",
      defaults: {},
      source_path: "/path/to/users_controller.rb"
    }
  ],
  "update" => [
    {
      verb: "PATCH",
      path: "/users",
      name: "edit_user",
      defaults: {},
      source_path: "/path/to/users_controller.rb"
    },
    {
      verb: "PUT",
      path: "/users",
      name: "edit_user",
      defaults: {},
      source_path: "/path/to/users_controller.rb"
    }
  ]
},
"empanadas" => {
  "create" => [
    {
      verb: "POST",
      path: "/empanadas",
      name: nil,
      defaults: {},
      source_path: "/path/to/empanadas_controller.rb"
    }
  ]
}
}

Returns:

  • Routes hash



53
54
55
56
57
58
# File 'lib/chusaku/routes.rb', line 53

def call
  routes = {}

  populate_routes(Rails.application, routes)
  backfill_routes(routes)
end