aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-01-25 10:16:50 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2013-01-30 10:24:57 -0800
commit2cdbe2270d2072249cd1622d843645e2813535bd (patch)
treee8c370fe04f80296ea31b521e42322bd7666f05f /actionpack/lib/action_dispatch/routing/route_set.rb
parentd783ba2029bf523faae7d5a53ccfabeffaf3ff6c (diff)
downloadrails-2cdbe2270d2072249cd1622d843645e2813535bd.tar.gz
rails-2cdbe2270d2072249cd1622d843645e2813535bd.tar.bz2
rails-2cdbe2270d2072249cd1622d843645e2813535bd.zip
moving more stuff on to the instance
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb36
1 files changed, 18 insertions, 18 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 6c2f39afb3..4864475172 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -182,6 +182,23 @@ module ActionDispatch
@route.requirements.except(:controller, :action).empty?
end
+ def optimized_helper
+ string_route = @route.ast.to_s
+
+ while string_route.gsub!(/\([^\)]*\)/, "")
+ true
+ end
+
+ @route.required_parts.each_with_index do |part, i|
+ # Replace each route parameter
+ # e.g. :id for regular parameter or *path for globbing
+ # with ruby string interpolation code
+ string_route.gsub!(/(\*|:)#{part}/, "\#{Journey::Router::Utils.escape_fragment(args[#{i}].to_param)}")
+ end
+
+ string_route
+ end
+
def url_else(t, args)
t.url_for(handle_positional_args(t, args, @options, @segment_keys))
end
@@ -225,7 +242,7 @@ module ActionDispatch
helper = UrlHelper.create(route, options.dup)
ohelp = helper.optimize_helper?
- ohelper = optimized_helper(route)
+ ohelper = helper.optimized_helper
arg_size = route.required_parts.size
@module.module_eval do
@@ -243,23 +260,6 @@ module ActionDispatch
helpers << name
end
- # Generates the interpolation to be used in the optimized helper.
- def optimized_helper(route)
- string_route = route.ast.to_s
-
- while string_route.gsub!(/\([^\)]*\)/, "")
- true
- end
-
- route.required_parts.each_with_index do |part, i|
- # Replace each route parameter
- # e.g. :id for regular parameter or *path for globbing
- # with ruby string interpolation code
- string_route.gsub!(/(\*|:)#{part}/, "\#{Journey::Router::Utils.escape_fragment(args[#{i}].to_param)}")
- end
-
- string_route
- end
end
attr_accessor :formatter, :set, :named_routes, :default_scope, :router