Class: Administrate::Namespace
- Inherits:
-
Object
- Object
- Administrate::Namespace
- Defined in:
- lib/administrate/namespace.rb,
lib/administrate/namespace/resource.rb
Defined Under Namespace
Classes: Resource
Instance Method Summary collapse
-
#initialize(namespace) ⇒ Namespace
constructor
A new instance of Namespace.
- #resources ⇒ Object
- #resources_with_index_route ⇒ Object
- #routes ⇒ Object
Constructor Details
#initialize(namespace) ⇒ Namespace
Returns a new instance of Namespace.
3 4 5 |
# File 'lib/administrate/namespace.rb', line 3 def initialize(namespace) @namespace = namespace.to_sym end |
Instance Method Details
#resources ⇒ Object
7 8 9 10 11 |
# File 'lib/administrate/namespace.rb', line 7 def resources @resources ||= routes.map(&:first).uniq.map do |path| Resource.new(namespace, path) end end |
#resources_with_index_route ⇒ Object
27 28 29 |
# File 'lib/administrate/namespace.rb', line 27 def resources_with_index_route routes.select { |_resource, route| route == "index" }.map(&:first).uniq end |
#routes ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/administrate/namespace.rb', line 13 def routes @routes ||= begin prefix = "#{namespace}/".freeze Rails.application.routes.routes.filter_map do |route| next unless route.defaults[:controller]&.start_with?(prefix) [ route.defaults[:controller].delete_prefix(prefix), route.defaults[:action] ] end end end |