提交 05eea6a2 编写于 作者: A Aaron Patterson

only process `via` once

we can directly turn it in to a regular expression here, so we don't
need to test its value twice
上级 2ae68eef
......@@ -109,6 +109,7 @@ def initialize(set, ast, defaults, controller, default_action, modyoule, to, for
@default_action = default_action
@ast = ast
@anchor = anchor
@via = via
path_params = ast.find_all(&:symbol?).map(&:to_sym)
......@@ -140,9 +141,6 @@ def initialize(set, ast, defaults, controller, default_action, modyoule, to, for
@defaults = formats[:defaults].merge(@defaults).merge(normalize_defaults(options))
@required_defaults = (split_options[:required_defaults] || []).map(&:first)
unless via == [:all]
@conditions[:request_method] = via.map { |m| m.to_s.dasherize.upcase }
end
end
def application
......@@ -164,8 +162,8 @@ def build_conditions(current_conditions, request_class)
# :request_method represents the HTTP verb that matches this route.
#
# Here we munge values before they get sent on to rack-mount.
verbs = conditions[:request_method] || []
unless verbs.empty?
unless @via == [:all]
verbs = @via.map { |m| m.to_s.dasherize.upcase }
conditions[:request_method] = %r[^#{verbs.join('|')}$]
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册