Skip to content
Browse files

only do is_a checks on `formatted` once

  • Loading branch information...
1 parent 10c1787 commit 5029c371fe398c915b0291be7ea54a8937cffa76 @tenderlove tenderlove committed
Showing with 5 additions and 9 deletions.
  1. +5 −9 actionpack/lib/action_dispatch/routing/mapper.rb
View
14 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -110,7 +110,7 @@ def initialize(scope, path, options)
@conditions[:parsed_path_info] = ast
add_request_method(via, @conditions)
- normalize_defaults!(options, formatted)
+ normalize_defaults!(options)
end
def to_route
@@ -177,8 +177,10 @@ def normalize_format!(formatted)
@requirements[:format] ||= /.+/
elsif Regexp === formatted
@requirements[:format] = formatted
+ @defaults[:format] = nil
elsif String === formatted
@requirements[:format] = Regexp.compile(formatted)
+ @defaults[:format] = formatted
end
end
@@ -192,18 +194,12 @@ def verify_regexp_requirement(requirement)
end
end
- def normalize_defaults!(options, formatted)
- options.each do |key, default|
+ def normalize_defaults!(options)
+ options.each_pair do |key, default|
unless Regexp === default
@defaults[key] = default
end
end
-
- if Regexp === formatted
- @defaults[:format] = nil
- elsif String === formatted
- @defaults[:format] = formatted
- end
end
def verify_callable_constraint(callable_constraint)

0 comments on commit 5029c37

Please sign in to comment.
Something went wrong with that request. Please try again.