aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2019-04-11 18:43:58 -0400
committerGitHub <noreply@github.com>2019-04-11 18:43:58 -0400
commit98e10c2deab755f49941676965cb8e30a843b4a5 (patch)
tree7d704c77ab07b929232c02048fac046138cfb52d /actionpack
parent032d4ad42cea834303a1fb9dccfda834ae42d221 (diff)
parentfdfd9e399f440fc6b4bec7d16ae5114318aee1a9 (diff)
downloadrails-98e10c2deab755f49941676965cb8e30a843b4a5.tar.gz
rails-98e10c2deab755f49941676965cb8e30a843b4a5.tar.bz2
rails-98e10c2deab755f49941676965cb8e30a843b4a5.zip
Merge pull request #35919 from Shopify/simplify-define_url_helper
Simplify and fasten NamedRouteCollection#define_url_helper
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb22
1 files changed, 10 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index d0a7eadf45..4a24c35efb 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -317,18 +317,16 @@ module ActionDispatch
#
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