Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (26 sloc) 688 Bytes
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
You can’t perform that action at this time.