Sha256: c11e5de64e15cf1f23a72925b48d0a76888d67025d48ed7fb0d53f9d1dbd28a1
Contents?: true
Size: 639 Bytes
Versions: 1
Compression:
Stored size: 639 Bytes
Contents
module Administrate class Namespace def initialize(namespace) @namespace = namespace end def resources @resources ||= routes.map(&:first).uniq.map(&:to_sym) end def routes @routes ||= all_routes.select do |controller, _action| controller.starts_with?(namespace.to_s) 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
administrate-0.5.0 | lib/administrate/namespace.rb |