class Dbla::Routes

Public Class Methods

for(router, *resources) click to toggle source
# File lib/dbla/routes.rb, line 4
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

Public Instance Methods

collection_routing(primary_resource) click to toggle source
# File lib/dbla/routes.rb, line 30
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
draw() click to toggle source
# File lib/dbla/routes.rb, line 12
def draw
  item_routing(primary_resource)
  collection_routing(primary_resource)
end
item_routing(primary_resource) click to toggle source
# File lib/dbla/routes.rb, line 17
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