class ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper::OptimizedUrlHelper

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::OptimizedUrlHelper < ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper::UrlHelper
  
  type ActionDispatch__Routing__RouteSet__NamedRouteCollection__UrlHelper__OptimizedUrlHelper_call_t = #<Class:0x000000010dc1f968> | Module | GemMetadata | #<Class:0x000000010e577308> | #<Class:0x0000000112c956e0> | #<Class:0x00000001075997e8> | #<Class:0x000000010c9dfbe0> | Gems::Metadata | #<Class:0x0000000115cd6548> | #<Class:0x00000001088ddd40> | #<Class:0x0000000106a15340>
  
  def call: (ActionDispatch__Routing__RouteSet__NamedRouteCollection__UrlHelper__OptimizedUrlHelper_call_t t, Symbol method_name, (Array[] | Array[String]) args, Hash? inner_options, Proc url_strategy) -> String
  
  type ActionDispatch__Routing__RouteSet__NamedRouteCollection__UrlHelper__OptimizedUrlHelper_optimize_routes_generation?_t = #<Class:0x000000011692cf90> | #<Class:0x0000000114da1550> | #<Class:0x0000000112d152a0> | #<Class:0x000000010fd1fb40> | Gems::Metadata | #<Class:0x000000011a85b7c0> | Worker::ListItemComponent
  
  def optimize_routes_generation?: (ActionDispatch__Routing__RouteSet__NamedRouteCollection__UrlHelper__OptimizedUrlHelper_optimize_routes_generation?_t t) -> true
  def optimized_helper: ((Array[] | Array[User]) args) -> String
  def parameterize_args: ((Array[] | Array[User]) args) -> Hash
end

def call(t, method_name, args, inner_options, url_strategy)

Experimental RBS support (using type sampling data from the type_fusion project).

type ActionDispatch__Routing__RouteSet__NamedRouteCollection__UrlHelper__OptimizedUrlHelper_call_t = #<Class:0x000000010dc1f968> | Module | GemMetadata | #<Class:0x000000010e577308> | #<Class:0x0000000112c956e0> | #<Class:0x00000001075997e8> | #<Class:0x000000010c9dfbe0> | Gems::Metadata | #<Class:0x0000000115cd6548> | #<Class:0x00000001088ddd40> | #<Class:0x0000000106a15340>

def call: (ActionDispatch__Routing__RouteSet__NamedRouteCollection__UrlHelper__OptimizedUrlHelper_call_t t, Symbol method_name,  args, [["relative_url_root", "String"]]? inner_options, Proc url_strategy) -> String

This signature was generated using 11 samples from 2 applications.

def call(t, method_name, args, inner_options, url_strategy)
  if args.size == arg_size && !inner_options && optimize_routes_generation?(t)
    options = t.url_options.merge @options
    path = optimized_helper(args)
    path << "/" if options[:trailing_slash] && !path.end_with?("/")
    options[:path] = path
    original_script_name = options.delete(:original_script_name)
    script_name = t._routes.find_script_name(options)
    if original_script_name
      script_name = original_script_name + script_name
    end
    options[:script_name] = script_name
    url_strategy.call options
  else
    super
  end
end

def initialize(route, options, route_name)

def initialize(route, options, route_name)
  super
  @required_parts = @route.required_parts
  @arg_size       = @required_parts.size
end

def optimize_routes_generation?(t)

Experimental RBS support (using type sampling data from the type_fusion project).

type ActionDispatch__Routing__RouteSet__NamedRouteCollection__UrlHelper__OptimizedUrlHelper_optimize_routes_generation?_t = #<Class:0x000000011692cf90> | #<Class:0x0000000114da1550> | #<Class:0x0000000112d152a0> | #<Class:0x000000010fd1fb40> | Gems::Metadata | #<Class:0x000000011a85b7c0> | Worker::ListItemComponent

def optimize_routes_generation?: (ActionDispatch__Routing__RouteSet__NamedRouteCollection__UrlHelper__OptimizedUrlHelper_optimize_routes_generation?_t t) -> true

This signature was generated using 8 samples from 2 applications.

def optimize_routes_generation?(t)
  t.send(:optimize_routes_generation?)
end

def optimized_helper(args)

Experimental RBS support (using type sampling data from the type_fusion project).

def optimized_helper: ( args) -> String

This signature was generated using 5 samples from 2 applications.

def optimized_helper(args)
  params = parameterize_args(args) do
    raise_generation_error(args)
  end
  @route.format params
end

def parameterize_args(args)

Experimental RBS support (using type sampling data from the type_fusion project).

def parameterize_args: ( args) ->

This signature was generated using 13 samples from 2 applications.

def parameterize_args(args)
  params = {}
  @arg_size.times { |i|
    key = @required_parts[i]
    value = args[i].to_param
    yield key if value.nil? || value.empty?
    params[key] = value
  }
  params
end

def raise_generation_error(args)

def raise_generation_error(args)
  missing_keys = []
  params = parameterize_args(args) { |missing_key|
    missing_keys << missing_key
  }
  constraints = Hash[@route.requirements.merge(params).sort_by { |k, v| k.to_s }]
  message = +"No route matches #{constraints.inspect}"
  message << ", missing required keys: #{missing_keys.sort.inspect}"
  raise ActionController::UrlGenerationError, message
end