Sha256: 3e548593843c1328f55984e8ac927e82fad550a0bb6800d1bcd46dfca38cbad5

Contents?: true

Size: 871 Bytes

Versions: 3

Compression:

Stored size: 871 Bytes

Contents

module Avo
  class DynamicRouter
    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::App.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.new.route_key do
                member do
                  get :preview
                end
              end
            end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
avo-3.0.0.pre3 lib/avo/dynamic_router.rb
avo-3.0.0.pre2 lib/avo/dynamic_router.rb
avo-3.0.0.pre1 lib/avo/dynamic_router.rb