Sha256: 287088f6605f5501920f2315eeb037e4946d0ce8e0a3ba6fea0f7a7cb214cb52
Contents?: true
Size: 860 Bytes
Versions: 7
Compression:
Stored size: 860 Bytes
Contents
## # Support the `:controller` and `:action` options. # # @example # get :admins, controller: :users # @example # post :search, action: :index module Rage::Router::DSLPlugins::ControllerActionOptions %i(get post put patch delete).each do |action_name| define_method(action_name) do |*args, **kwargs| if args.length == 1 && !kwargs.has_key?(:to) && (kwargs.has_key?(:controller) || kwargs.has_key?(:action)) path = args[0] controller = kwargs.delete(:controller) || @controllers.last || raise(ArgumentError, "Could not derive the controller value from the route definitions") action = kwargs.delete(:action) || path.split("/").last end if controller && action kwargs[:to] = "#{controller}##{action}" super(path, **kwargs) else super(*args, **kwargs) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems