Sha256: 5a3a85d33f75a10739daf90b4802a67de5b85fe8fdae4fb556b0919b466a6234

Contents?: true

Size: 1.02 KB

Versions: 47

Compression:

Stored size: 1.02 KB

Contents

module Para
  class Routes
    class_attribute :routes_extensions

    attr_reader :router

    def initialize(router)
      @router = router
    end

    def draw(mount_location = '/', &block)
      router.instance_eval do
        scope mount_location do
          scope module: :para do
            namespace :admin do
              get '/' => 'main#index'
              get '/search' => 'search#index', as: :search
            end

            # Components are namespaced into :admin in their respective methods
            crud_component scoped_in_para: true
            form_component scoped_in_para: true
            component :settings, scoped_in_para: true
          end

          block.call if block
        end
      end
    end

    def self.extend_routes_for(component_type, &block)
      extensions = routes_extensions_for(component_type)
      extensions << block
    end

    def self.routes_extensions_for(component_type)
      self.routes_extensions ||= {}
      self.routes_extensions[component_type] ||= []
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
para-0.12.4 lib/para/routes.rb
para-0.12.3 lib/para/routes.rb
para-0.12.2 lib/para/routes.rb
para-0.12.1 lib/para/routes.rb
para-0.12.0 lib/para/routes.rb
para-0.11.4 lib/para/routes.rb
para-0.11.3 lib/para/routes.rb
para-0.11.2 lib/para/routes.rb
para-0.11.1 lib/para/routes.rb
para-0.11.0 lib/para/routes.rb
para-0.10.0 lib/para/routes.rb
para-0.9.4 lib/para/routes.rb
para-0.9.3.3 lib/para/routes.rb
para-0.9.3.2 lib/para/routes.rb
para-0.9.3.1 lib/para/routes.rb
para-0.9.2 lib/para/routes.rb
para-0.9.0 lib/para/routes.rb
para-0.8.15 lib/para/routes.rb
para-0.8.14 lib/para/routes.rb
para-0.8.13 lib/para/routes.rb