Class: Dbla::Routes

Inherits:
Blacklight::Routes
  • Object
show all
Defined in:
lib/dbla/routes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(router, *resources) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/dbla/routes.rb', line 5

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

Instance Method Details

#collection_routing(primary_resource) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dbla/routes.rb', line 31

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

#drawObject



13
14
15
16
# File 'lib/dbla/routes.rb', line 13

def draw
  item_routing(primary_resource)
  collection_routing(primary_resource)
end

#item_routing(primary_resource) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dbla/routes.rb', line 18

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