only do is_a checks on formatted
once
This commit is contained in:
parent
10c1787b30
commit
5029c371fe
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user