Sha256: 2f4fe7314e92a961a957e3ec54f175e186709d81453636df2c81ced69a1222a2
Contents?: true
Size: 795 Bytes
Versions: 17
Compression:
Stored size: 795 Bytes
Contents
module Madmin class Namespace def initialize(namespace) @namespace = namespace end def resources @resources ||= routes.map(&:first).uniq.map { |path| Resource.new(namespace, path) } end def routes @routes ||= all_routes.select { |controller, _action| controller.starts_with?("#{namespace}/") }.map { |controller, action| [controller.gsub(/^#{namespace}\//, ""), action] } end def resources_with_index_route routes.select { |_resource, route| route == "index" }.map(&:first).uniq end private attr_reader :namespace def all_routes Rails.application.routes.routes.map do |route| route.defaults.values_at(:controller, :action).map(&:to_s) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems