diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-01-25 10:14:37 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-01-30 10:24:57 -0800 |
commit | d783ba2029bf523faae7d5a53ccfabeffaf3ff6c (patch) | |
tree | 75c79ed3baea989f4d877de6294d4337c6e35590 /actionpack/lib | |
parent | 532e12287eb9b14583d2f97262f244fc28de6f24 (diff) | |
download | rails-d783ba2029bf523faae7d5a53ccfabeffaf3ff6c.tar.gz rails-d783ba2029bf523faae7d5a53ccfabeffaf3ff6c.tar.bz2 rails-d783ba2029bf523faae7d5a53ccfabeffaf3ff6c.zip |
move optimize_helper? to the helper instance
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 8a78e49071..6c2f39afb3 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -173,8 +173,13 @@ module ActionDispatch 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 @@ module ActionDispatch # 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 @@ module ActionDispatch 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 |