class ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/action_dispatch/routing/route_set.rbs class ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper def handle_positional_args: (Hash controller_options, Hash inner_options, Array[String] args, Hash result, Array[Symbol] path_params) -> untyped end
def self.create(route, options, route_name)
def self.create(route, options, route_name) if optimize_helper?(route) OptimizedUrlHelper.new(route, options, route_name) else new(route, options, route_name) end end
def self.optimize_helper?(route)
def self.optimize_helper?(route) route.path.requirements.empty? && !route.glob? end
def call(t, method_name, args, inner_options, url_strategy)
def call(t, method_name, args, inner_options, url_strategy) controller_options = t.url_options options = controller_options.merge @options hash = handle_positional_args(controller_options, inner_options || {}, args, options, @segment_keys) t._routes.url_for(hash, route_name, url_strategy, method_name) end
def handle_positional_args(controller_options, inner_options, args, result, path_params)
Experimental RBS support (using type sampling data from the type_fusion
project).
def handle_positional_args: ( controller_options, inner_options, String | String args, controller | String | action | String result, Symbol | Symbol | Symbol path_params) -> untyped
This signature was generated using 1 sample from 1 application.
def handle_positional_args(controller_options, inner_options, args, result, path_params) if args.size > 0 # take format into account if path_params.include?(:format) path_params_size = path_params.size - 1 else path_params_size = path_params.size end if args.size < path_params_size path_params -= controller_options.keys path_params -= result.keys else path_params = path_params.dup end inner_options.each_key do |key| path_params.delete(key) end args.each_with_index do |arg, index| param = path_params[index] result[param] = arg if param end end result.merge!(inner_options) end
def initialize(route, options, route_name)
def initialize(route, options, route_name) @options = options @segment_keys = route.segment_keys.uniq @route = route @route_name = route_name end