Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

No need to create a separate lambda for each call.

  • Loading branch information...
commit 86bcccf8dfced5e9428407a71f02c1dcc186f2ba 1 parent 7b2d518
@thedarkone thedarkone authored
Showing with 14 additions and 15 deletions.
  1. +14 −15 actionpack/lib/action_dispatch/routing/route_set.rb
View
29 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -334,6 +334,19 @@ def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil
end
class Generator #:nodoc:
+ PARAMETERIZE = {
+ :parameterize => lambda do |name, value|
+ if name == :controller
+ value
+ elsif value.is_a?(Array)
+ value.map { |v| Rack::Mount::Utils.escape_uri(v.to_param) }.join('/')
+ else
+ return nil unless param = value.to_param
+ param.split('/').map { |v| Rack::Mount::Utils.escape_uri(v) }.join("/")
+ end
+ end
+ }
+
attr_reader :options, :recall, :set, :named_route
def initialize(options, recall, set, extras = false)
@@ -422,7 +435,7 @@ def handle_nil_action!
end
def generate
- path, params = @set.set.generate(:path_info, named_route, options, recall, opts)
+ path, params = @set.set.generate(:path_info, named_route, options, recall, PARAMETERIZE)
raise_routing_error unless path
@@ -436,20 +449,6 @@ def generate
raise_routing_error
end
- def opts
- parameterize = lambda do |name, value|
- if name == :controller
- value
- elsif value.is_a?(Array)
- value.map { |v| Rack::Mount::Utils.escape_uri(v.to_param) }.join('/')
- else
- return nil unless param = value.to_param
- param.split('/').map { |v| Rack::Mount::Utils.escape_uri(v) }.join("/")
- end
- end
- {:parameterize => parameterize}
- end
-
def raise_routing_error
raise ActionController::RoutingError.new("No route matches #{options.inspect}")
end
Please sign in to comment.
Something went wrong with that request. Please try again.