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.
This commit is contained in:
Łukasz Strzałkowski 2013-12-08 22:11:46 +01:00
parent 99975e742e
commit 9b8c0ff391
1 changed files with 1 additions and 1 deletions

View File

@ -430,7 +430,7 @@ module ActionController #:nodoc:
def initialize(mimes)
@responses = {}
mimes.each { |mime| send(mime) }
mimes.each { |mime| @responses["Mime::#{mime.upcase}".constantize] = nil }
end
def any(*args, &block)