提交 9b8c0ff3 编写于 作者: Ł Łukasz Strzałkowski

Simplify @responses hash initialization

@responses hash needs to be initialized with mime types that we get from
Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as
value. This need to happen before content negotiation. Before that, it was
looping though mime types and executing mime-type-generated method inside
collector (see
AbstractController::Collector#generate_method_for_mime). That approach resulted
in 2 unnecessary method calls for each mime type
collected by Collector#collect_mimes_from_class_level.

Now hash is initialized in place, without usage of Collector#custom method.
上级 99975e74
...@@ -430,7 +430,7 @@ class Collector ...@@ -430,7 +430,7 @@ class Collector
def initialize(mimes) def initialize(mimes)
@responses = {} @responses = {}
mimes.each { |mime| send(mime) } mimes.each { |mime| @responses["Mime::#{mime.upcase}".constantize] = nil }
end end
def any(*args, &block) def any(*args, &block)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册