diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2012-05-02 18:31:45 +0300 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2012-05-02 18:31:45 +0300 |
commit | da88d800b8e67841af8b4270c13bcac4559b6f74 (patch) | |
tree | 934c1c3eac8e7493d3baa70ed44a99edc691d0ef /actionpack/lib | |
parent | 02f2e3d538f79d61ab5abdcdb3bea30843d3ee4a (diff) | |
download | rails-da88d800b8e67841af8b4270c13bcac4559b6f74.tar.gz rails-da88d800b8e67841af8b4270c13bcac4559b6f74.tar.bz2 rails-da88d800b8e67841af8b4270c13bcac4559b6f74.zip |
RouteSet: remove some code dups
Diffstat (limited to 'actionpack/lib')
-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 |