Skip to content
This repository
Browse code

Merge pull request #6138 from bogdan/routes

RouteSet: remove some code dups
  • Loading branch information...
commit 5c0cbb3d2f0aa3bf73bb628ea720fa08beb701b6 2 parents 3e54179 + da88d80
José Valim authored May 03, 2012
29  actionpack/lib/action_dispatch/routing/route_set.rb
@@ -184,27 +184,18 @@ def define_named_route_methods(name, route)
184 184
           def define_url_helper(route, name, options)
185 185
             selector = url_helper_name(name, options[:only_path])
186 186
 
187  
-            if optimize_helper?(route)
188  
-              @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
189  
-                remove_possible_method :#{selector}
190  
-                def #{selector}(*args)
191  
-                  if args.size == #{route.required_parts.size} && !args.last.is_a?(Hash) && optimize_routes_generation?
192  
-                    options = #{options.inspect}.merge!(url_options)
193  
-                    options[:path] = "#{optimized_helper(route)}"
194  
-                    ActionDispatch::Http::URL.url_for(options)
195  
-                  else
196  
-                    url_for(handle_positional_args(args, #{options.inspect}, #{route.segment_keys.inspect}))
197  
-                  end
198  
-                end
199  
-              END_EVAL
200  
-            else
201  
-              @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
202  
-                remove_possible_method :#{selector}
203  
-                def #{selector}(*args)
  187
+            @module.module_eval <<-END_EVAL, __FILE__, __LINE__ + 1
  188
+              remove_possible_method :#{selector}
  189
+              def #{selector}(*args)
  190
+                if #{optimize_helper?(route)} && args.size == #{route.required_parts.size} && !args.last.is_a?(Hash) && optimize_routes_generation?
  191
+                  options = #{options.inspect}.merge!(url_options)
  192
+                  options[:path] = "#{optimized_helper(route)}"
  193
+                  ActionDispatch::Http::URL.url_for(options)
  194
+                else
204 195
                   url_for(handle_positional_args(args, #{options.inspect}, #{route.segment_keys.inspect}))
205 196
                 end
206  
-              END_EVAL
207  
-            end
  197
+              end
  198
+            END_EVAL
208 199
 
209 200
             helpers << selector
210 201
           end

0 notes on commit 5c0cbb3

Please sign in to comment.
Something went wrong with that request. Please try again.