diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-07-16 11:54:53 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-07-16 11:55:05 -0700 |
commit | f636652dd52ed36f7438c0436679c987cdfefb82 (patch) | |
tree | 620c6c788d7d2dc4542422f85668ba0d012265d1 /actionpack/lib/action_dispatch/routing | |
parent | d12b30f99700721114891c37be217a2888393feb (diff) | |
download | rails-f636652dd52ed36f7438c0436679c987cdfefb82.tar.gz rails-f636652dd52ed36f7438c0436679c987cdfefb82.tar.bz2 rails-f636652dd52ed36f7438c0436679c987cdfefb82.zip |
extract inner options before delegating to the helper
If we extract the options from the user facing method call ASAP, then we
can simplify internal logic.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 1ee74e6810..d24751d28d 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -155,8 +155,8 @@ module ActionDispatch @arg_size = @required_parts.size end - def call(t, args) - if args.size == arg_size && !args.last.is_a?(Hash) && optimize_routes_generation?(t) + 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) ActionDispatch::Http::URL.url_for(options) @@ -207,15 +207,19 @@ module ActionDispatch @route = route end - def call(t, args) + def call(t, args, inner_options) controller_options = t.url_options options = controller_options.merge @options - hash = handle_positional_args(controller_options, args, options, @segment_keys) + hash = handle_positional_args(controller_options, + inner_options || {}, + args, + options, + @segment_keys) + t._routes.url_for(hash) end - def handle_positional_args(controller_options, args, result, path_params) - inner_options = args.extract_options! + def handle_positional_args(controller_options, inner_options, args, result, path_params) if args.size > 0 if args.size < path_params.size - 1 # take format into account @@ -251,7 +255,9 @@ module ActionDispatch @module.remove_possible_method name @module.module_eval do define_method(name) do |*args| - helper.call self, args + options = nil + options = args.pop if args.last.is_a? Hash + helper.call self, args, options end end |