module Pup::RouteHelpers
Public Instance Methods
resources(resource, options = {})
click to toggle source
# 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)
click to toggle source
# File lib/pup/routing/route_helpers.rb, line 3 def root(target) get("/", to: target) end
Private Instance Methods
get_required_actions(options)
click to toggle source
# File lib/pup/routing/route_helpers.rb, line 22 def get_required_actions(options) actions = [:index, :new, :create, :show, :edit, :update, :destroy] actions -= options[:except] if options.key?(:except) actions &= options[:only] if options.key?(:only) actions end