Module: Pup::RouteHelpers

Included in:
Pup::Routing::Router
Defined in:
lib/pup/routing/route_helpers.rb

Instance Method Summary collapse

Instance Method Details

#resources(resource, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pup/routing/route_helpers.rb', line 7

def resources(resource, options = {})
  actions = get_required_actions(options)

  # rubocop:disable Metrics/LineLength
  get("/#{resource}", to: "#{resource}#index") if actions.include?(:index)
  get("/#{resource}/new", to: "#{resource}#new") if actions.include?(:new)
  post("/#{resource}", to: "#{resource}#create") if actions.include?(:create)
  get("/#{resource}/:id", to: "#{resource}#show") if actions.include?(:show)
  get("/#{resource}/:id/edit", to: "#{resource}#edit") if actions.include?(:edit)
  put("/#{resource}/:id", to: "#{resource}#update") if actions.include?(:update)
  patch("/#{resource}/:id", to: "#{resource}#update") if actions.include?(:update)
  delete("/#{resource}/:id", to: "#{resource}#destroy") if actions.include?(:destroy)
  # rubocop:enable Metrics/LineLength
end

#root(target) ⇒ Object



3
4
5
# File 'lib/pup/routing/route_helpers.rb', line 3

def root(target)
  get("/", to: target)
end