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
- #index_resources ⇒ Object
-
#initialize(namespace) ⇒ Namespace
constructor
A new instance of Namespace.
- #resources ⇒ 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 end |
Instance Method Details
#index_resources ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/administrate/namespace.rb', line 13 def index_resources @index_resources ||= begin index_routes = routes.select do |_path, action| action == "index" end index_routes.uniq! index_routes.map do |route| path = route[0] ::Administrate::Namespace::Resource.new(namespace, path) end end end |
#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 |
#routes ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/administrate/namespace.rb', line 29 def routes @routes ||= all_routes.select do |controller, _action| controller.starts_with?("#{namespace}/") end.map do |controller, action| [controller.gsub(/^#{namespace}\//, ""), action] end end |