Module: Vitrage::Router

Included in:
Vitrage
Defined in:
lib/vitrage/router.rb

Instance Method Summary collapse

Instance Method Details

#routes(rails_router, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vitrage/router.rb', line 4

def routes(rails_router, options = {})
  if options[:controller]
    cs = options[:controller].to_s
    rails_router.post   '/vitrage/pieces'           => "#{cs}#create", as: :vitrage_pieces
    rails_router.get    '/vitrage/pieces/new'       => "#{cs}#new",    as: :new_vitrage_piece
    rails_router.get    '/vitrage/pieces/:id/edit'  => "#{cs}#edit",   as: :edit_vitrage_piece
    rails_router.get    '/vitrage/pieces/:id'       => "#{cs}#show",   as: :vitrage_piece
    rails_router.match  '/vitrage/pieces/:id'       => "#{cs}#update", via: [:patch, :put]
    rails_router.delete '/vitrage/pieces/:id'       => "#{cs}#destroy"
  else
    rails_router.namespace :vitrage do
      rails_router.resources :pieces, except: [:index]
    end
  end
end