Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moving more stuff on to the instance

  • Loading branch information...
commit 2cdbe2270d2072249cd1622d843645e2813535bd 1 parent d783ba2
Aaron Patterson tenderlove authored
Showing with 18 additions and 18 deletions.
  1. +18 −18 actionpack/lib/action_dispatch/routing/route_set.rb
36 actionpack/lib/action_dispatch/routing/route_set.rb
View
@@ -182,6 +182,23 @@ def optimize_helper?
@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 @@ def define_url_helper(route, name, options)
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 @@ def define_url_helper(route, name, options)
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
Please sign in to comment.
Something went wrong with that request. Please try again.