Sha256: e8321d8482e4960e47d218bc1fa31004f2ccbd7bedb9ae41b7138c57993d428b
Contents?: true
Size: 688 Bytes
Versions: 5
Compression:
Stored size: 688 Bytes
Contents
module Administrate class Namespace def initialize(namespace) @namespace = namespace end def resources @resources ||= routes.map(&:first).uniq.map do |path| Resource.new(namespace, path) end end def routes @routes ||= all_routes.select do |controller, _action| controller.starts_with?("#{namespace}/") end.map do |controller, action| [controller.gsub(/^#{namespace}\//, ""), action] end 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
5 entries across 5 versions & 2 rubygems