Sha256: a7d56f9a8cec138c99a24d53da7493d60dc431a3973e9851de2fc414a7022e8f

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

# -*- encoding : utf-8 -*-
module Dbla
  class Routes < Blacklight::Routes

    def self.for(router, *resources)
        raise_no_blacklight_secret_key unless Blacklight.secret_key
        options = resources.extract_options!
        resources.map!(&:to_sym)

        Dbla::Routes.new(router, options.merge(resources: resources)).draw
    end

    def draw
      item_routing(primary_resource)
      collection_routing(primary_resource)
    end

    def item_routing(primary_resource)
      add_routes do |options|
        args = {only: [:show]}
        args[:constraints] = options[:constraints] if options[:constraints]

        resources :item, args.merge(path: primary_resource, controller: primary_resource) do
          member do
            post "track"
          end
        end
      end
    end

    def collection_routing(primary_resource)
      add_routes do |options|
        args = {only: [:show]}
        args[:constraints] = options[:constraints] if options[:constraints]

        resources :collection, args.merge(path: primary_resource, controller: primary_resource) do
          member do
            post "track"
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dbla-0.0.8 lib/dbla/routes.rb
dbla-0.0.7 lib/dbla/routes.rb
dbla-0.0.6 lib/dbla/routes.rb
dbla-0.0.5 lib/dbla/routes.rb
dbla-0.0.4 lib/dbla/routes.rb
dbla-0.0.3 lib/dbla/routes.rb
dbla-0.0.2 lib/dbla/routes.rb
dbla-0.0.1 lib/dbla/routes.rb