only do is_a checks on formatted once

This commit is contained in:
Aaron Patterson 2014-05-30 15:14:04 -07:00
parent 10c1787b30
commit 5029c371fe

@ -110,7 +110,7 @@ def initialize(scope, path, options)
@conditions[:parsed_path_info] = ast @conditions[:parsed_path_info] = ast
add_request_method(via, @conditions) add_request_method(via, @conditions)
normalize_defaults!(options, formatted) normalize_defaults!(options)
end end
def to_route def to_route
@ -177,8 +177,10 @@ def normalize_format!(formatted)
@requirements[:format] ||= /.+/ @requirements[:format] ||= /.+/
elsif Regexp === formatted elsif Regexp === formatted
@requirements[:format] = formatted @requirements[:format] = formatted
@defaults[:format] = nil
elsif String === formatted elsif String === formatted
@requirements[:format] = Regexp.compile(formatted) @requirements[:format] = Regexp.compile(formatted)
@defaults[:format] = formatted
end end
end end
@ -192,18 +194,12 @@ def verify_regexp_requirement(requirement)
end end
end end
def normalize_defaults!(options, formatted) def normalize_defaults!(options)
options.each do |key, default| options.each_pair do |key, default|
unless Regexp === default unless Regexp === default
@defaults[key] = default @defaults[key] = default
end end
end end
if Regexp === formatted
@defaults[:format] = nil
elsif String === formatted
@defaults[:format] = formatted
end
end end
def verify_callable_constraint(callable_constraint) def verify_callable_constraint(callable_constraint)