Class: Avo::DynamicRouter
- Inherits:
-
Object
- Object
- Avo::DynamicRouter
- Defined in:
- lib/avo/dynamic_router.rb
Class Method Summary collapse
Class Method Details
.eager_load(entity) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/avo/dynamic_router.rb', line 3 def self.eager_load(entity) paths = Avo::ENTITIES.fetch entity return unless paths.present? pathname = Rails.root.join(*paths) if pathname.directory? Rails.autoloaders.main.eager_load_dir(pathname.to_s) end end |
.routes ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/avo/dynamic_router.rb', line 14 def self.routes Avo::Engine.routes.draw do scope "resources", as: "resources" do # Check if the user chose to manually register the resource files. # If so, eager_load the resources dir. if Avo.configuration.resources.nil? Avo::DynamicRouter.eager_load(:resources) unless Rails.application.config.eager_load end Avo::Resources::ResourceManager.fetch_resources .select do |resource| resource != :BaseResource end .select do |resource| resource.is_a? Class end .map do |resource| resources resource.route_key do member do get :preview end end end end end end |