Permalink
Browse files

move optimize_helper? to the helper instance

  • Loading branch information...
1 parent 532e122 commit d783ba2029bf523faae7d5a53ccfabeffaf3ff6c @tenderlove tenderlove committed Jan 25, 2013
Showing with 12 additions and 9 deletions.
  1. +12 −9 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -173,8 +173,13 @@ def self.create(route, options)
end
def initialize(route, options)
- @options = options
+ @options = options
@segment_keys = route.segment_keys
+ @route = route
+ end
+
+ def optimize_helper?
+ @route.requirements.except(:controller, :action).empty?
end
def url_else(t, args)
@@ -216,14 +221,17 @@ def define_url_helper(route, name, options)
# end
# end
#END_EVAL
- ohelp = optimize_helper?(route)
- ohelper = optimized_helper(route)
- arg_size = route.required_parts.size
helper = UrlHelper.create(route, options.dup)
+ ohelp = helper.optimize_helper?
+ ohelper = optimized_helper(route)
+ arg_size = route.required_parts.size
+
@module.module_eval do
define_method(name) do |*args|
+ #helper.call t, args
+
if ohelp && args.size == arg_size && !args.last.is_a?(Hash) && optimize_routes_generation?
helper.url_if(self, eval("\"#{ohelper}\""))
else
@@ -235,11 +243,6 @@ def define_url_helper(route, name, options)
helpers << name
end
- # Clause check about when we need to generate an optimized helper.
- def optimize_helper?(route) #:nodoc:
- route.requirements.except(:controller, :action).empty?
- end
-
# Generates the interpolation to be used in the optimized helper.
def optimized_helper(route)
string_route = route.ast.to_s

0 comments on commit d783ba2

Please sign in to comment.