diff options
author | José Valim <jose.valim@gmail.com> | 2012-05-03 01:50:08 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-05-03 01:50:08 -0700 |
commit | 5c0cbb3d2f0aa3bf73bb628ea720fa08beb701b6 (patch) | |
tree | 7b9f52e829c341f792702f6d4713b4d62f858031 | |
parent | 3e541799e5bf1ae5a9f377d8d5dfe42ef3e69549 (diff) | |
parent | da88d800b8e67841af8b4270c13bcac4559b6f74 (diff) | |
download | rails-5c0cbb3d2f0aa3bf73bb628ea720fa08beb701b6.tar.gz rails-5c0cbb3d2f0aa3bf73bb628ea720fa08beb701b6.tar.bz2 rails-5c0cbb3d2f0aa3bf73bb628ea720fa08beb701b6.zip |
Merge pull request #6138 from bogdan/routes
RouteSet: remove some code dups
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 6e685c84fd..57ce7b4ba9 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -184,27 +184,18 @@ module ActionDispatch def define_url_helper(route, name, options) selector = url_helper_name(name, options[:only_path]) - if optimize_helper?(route) - @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1 - remove_possible_method :#{selector} - def #{selector}(*args) - if args.size == #{route.required_parts.size} && !args.last.is_a?(Hash) && optimize_routes_generation? - options = #{options.inspect}.merge!(url_options) - options[:path] = "#{optimized_helper(route)}" - ActionDispatch::Http::URL.url_for(options) - else - url_for(handle_positional_args(args, #{options.inspect}, #{route.segment_keys.inspect})) - end - end - END_EVAL - else - @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1 - remove_possible_method :#{selector} - def #{selector}(*args) + @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1 + remove_possible_method :#{selector} + def #{selector}(*args) + if #{optimize_helper?(route)} && args.size == #{route.required_parts.size} && !args.last.is_a?(Hash) && optimize_routes_generation? + options = #{options.inspect}.merge!(url_options) + options[:path] = "#{optimized_helper(route)}" + ActionDispatch::Http::URL.url_for(options) + else url_for(handle_positional_args(args, #{options.inspect}, #{route.segment_keys.inspect})) end - END_EVAL - end + end + END_EVAL helpers << selector end |