Merge pull request #35919 from Shopify/simplify-define_url_helper
Simplify and fasten NamedRouteCollection#define_url_helper
This commit is contained in:
commit
98e10c2dea
@ -317,18 +317,16 @@ def handle_positional_args(controller_options, inner_options, args, result, path
|
||||
#
|
||||
def define_url_helper(mod, route, name, opts, route_key, url_strategy)
|
||||
helper = UrlHelper.create(route, opts, route_key, url_strategy)
|
||||
mod.module_eval do
|
||||
define_method(name) do |*args|
|
||||
last = args.last
|
||||
options = \
|
||||
case last
|
||||
when Hash
|
||||
args.pop
|
||||
when ActionController::Parameters
|
||||
args.pop.to_h
|
||||
end
|
||||
helper.call self, args, options
|
||||
end
|
||||
mod.define_method(name) do |*args|
|
||||
last = args.last
|
||||
options = \
|
||||
case last
|
||||
when Hash
|
||||
args.pop
|
||||
when ActionController::Parameters
|
||||
args.pop.to_h
|
||||
end
|
||||
helper.call self, args, options
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user