Sha256: 87d5a8c5b7976078b820c6be9d8b27f14d4939b0c37d5cb6a103df9a7e30537c

Contents?: true

Size: 867 Bytes

Versions: 10

Compression:

Stored size: 867 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.route_key do
                member do
                  get :preview
                end
              end
            end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
avo-3.0.0.pre13 lib/avo/dynamic_router.rb
avo-3.0.0.pre12 lib/avo/dynamic_router.rb
avo-3.0.0.pre10 lib/avo/dynamic_router.rb
avo-3.0.0.pre11 lib/avo/dynamic_router.rb
avo-3.0.0.pre8 lib/avo/dynamic_router.rb
avo-3.0.0.pre9 lib/avo/dynamic_router.rb
avo-3.0.0.pre7 lib/avo/dynamic_router.rb
avo-3.0.0.pre5 lib/avo/dynamic_router.rb
avo-3.0.0.pre6 lib/avo/dynamic_router.rb
avo-3.0.0.pre4 lib/avo/dynamic_router.rb