Permalink
Browse files

pushing specialization down to the optimized class

  • Loading branch information...
1 parent 026c40f commit 3bfdfc869b5c9fcd8397710aa7b0d211d549aa45 @tenderlove tenderlove committed Jan 25, 2013
Showing with 25 additions and 23 deletions.
  1. +25 −23 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -194,41 +194,43 @@ def call(t, args)
super
end
end
- end
- def initialize(route, options)
- @options = options
- @segment_keys = route.segment_keys
- @route = route
- end
+ private
- def arg_size
- @route.required_parts.size
- end
+ def optimized_helper
+ string_route = @route.ast.to_s
- 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
- while string_route.gsub!(/\([^\)]*\)/, "")
- true
+ string_route
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)}")
+ def arg_size
+ @route.required_parts.size
end
- string_route
+ def optimize_routes_generation?(t)
+ t.send(:optimize_routes_generation?)
+ end
end
- def call(t, args)
- t.url_for(handle_positional_args(t, args, @options, @segment_keys))
+ def initialize(route, options)
+ @options = options
+ @segment_keys = route.segment_keys
+ @route = route
end
- def optimize_routes_generation?(t)
- t.send(:optimize_routes_generation?)
+ def call(t, args)
+ t.url_for(handle_positional_args(t, args, @options, @segment_keys))
end
def handle_positional_args(t, args, options, segment_keys)

0 comments on commit 3bfdfc8

Please sign in to comment.