Class: ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper::OptimizedUrlHelper

Inherits:
ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper show all
Defined in:
lib/action_dispatch/routing/route_set.rb

Constant Summary

Constants inherited from ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper

DEPRECATED_STRING_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper

#route_name, #url_strategy

Instance Method Summary collapse

Methods inherited from ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper

create, #deprecate_string_options, #handle_positional_args, optimize_helper?

Constructor Details

#initialize(route, options, route_name, url_strategy) ⇒ OptimizedUrlHelper

Returns a new instance of OptimizedUrlHelper.



211
212
213
214
215
# File 'lib/action_dispatch/routing/route_set.rb', line 211

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

Instance Attribute Details

#arg_sizeObject (readonly)

Returns the value of attribute arg_size.



209
210
211
# File 'lib/action_dispatch/routing/route_set.rb', line 209

def arg_size
  @arg_size
end

Instance Method Details

#call(t, args, inner_options) ⇒ Object



217
218
219
220
221
222
223
224
225
# File 'lib/action_dispatch/routing/route_set.rb', line 217

def call(t, args, inner_options)
  if args.size == arg_size && !inner_options && optimize_routes_generation?(t)
    options = t.url_options.merge @options
    options[:path] = optimized_helper(args)
    url_strategy.call options
  else
    super
  end
end