Class: ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper
Do not use. This class is for internal use only.
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/routing/route_set.rb |
Class Method Summary
Instance Attribute Summary
- #route_name readonly
Instance Method Summary
Constructor Details
.new(route, options, route_name) ⇒ UrlHelper
# File 'actionpack/lib/action_dispatch/routing/route_set.rb', line 273
def initialize(route, , route_name) @options = @segment_keys = route.segment_keys.uniq @route = route @route_name = route_name end
Class Method Details
.create(route, options, route_name)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/route_set.rb', line 191
def self.create(route, , route_name) if optimize_helper?(route) OptimizedUrlHelper.new(route, , route_name) else new(route, , route_name) end end
.optimize_helper?(route) ⇒ Boolean
# File 'actionpack/lib/action_dispatch/routing/route_set.rb', line 199
def self.optimize_helper?(route) route.path.requirements.empty? && !route.glob? end
Instance Attribute Details
#route_name (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/route_set.rb', line 203
attr_reader :route_name
Instance Method Details
#call(t, method_name, args, inner_options, url_strategy)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/route_set.rb', line 280
def call(t, method_name, args, , url_strategy) = t. = .merge @options hash = handle_positional_args(, || {}, args, , @segment_keys) t._routes.url_for(hash, route_name, url_strategy, method_name) end
#handle_positional_args(controller_options, inner_options, args, result, path_params)
[ GitHub ]# File 'actionpack/lib/action_dispatch/routing/route_set.rb', line 292
def handle_positional_args(, , 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 -= .keys path_params -= (result[:path_params] || {}).merge(result).keys else path_params = path_params.dup end .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!( ) end