Sha256: 604d0422c9d72f54c01882e4e1c39c7c5db4b48adf08b5e34367021f614a23e1
Contents?: true
Size: 943 Bytes
Versions: 2
Compression:
Stored size: 943 Bytes
Contents
# frozen_string_literal: true module Chusaku module Routes # Extract information about the Rails project's routes. # # Example output: # # { # 'users' => { # 'edit' => { verb: 'GET', path: '/users/:id', name: 'edit_user' }, # 'update' => { verb: 'PUT', path: '/users', name: nil } # }, # 'empanadas' => { # 'create' => { verb: 'POST', path: '/empanadas', name: nil } # } # } # # @return {Hash} def self.call routes = {} Rails.application.routes.routes.each do |route| defaults = route.defaults action = defaults[:action] routes[defaults[:controller]] ||= {} routes[defaults[:controller]][action] = { verb: route.verb, path: route.path.spec.to_s.gsub('(.:format)', ''), name: route.name } end routes end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
chusaku-0.1.1 | lib/chusaku/routes.rb |
chusaku-0.1.0 | lib/chusaku/routes.rb |