Browse files

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.
  • Loading branch information...
lukaszx0 committed Dec 10, 2013
1 parent 4aae538 commit fbb6be50a55fef24cdef97c522d1acc9787cbf2a
Showing with 2 additions and 1 deletion.
  1. +2 −1 actionpack/lib/action_controller/metal/mime_responds.rb
@@ -430,7 +430,8 @@ class Collector
def initialize(mimes)
@responses = {}
- mimes.each { |mime| send(mime) }
+ mimes.each { |mime| @responses["Mime::#{mime.upcase}".constantize] = nil }
def any(*args, &block)

0 comments on commit fbb6be5

Please sign in to comment.