class ActionController::MimeResponds::Collector

request, with this response then being accessible by calling #response.
to determine which specific mime-type it should respond with for the current
A subsequent call to #negotiate_format(request) will enable the Collector
corresponding block if present.
as html, xml etc on the Collector. Each response is represented by a
calling any of the dynamically generated, mime-type-specific methods such
object serves as a container in which available responses can be stored by
instance of the ActionController::MimeResponds::Collector class. This
In this usage, the argument passed to the block (format above) is an
end
format.xml { render xml: @people }
format.html
respond_to do |format|
for respond_to :
with a block that is used to define responses to different mime-types, e.g.
The public controller methods respond_with and respond_to may be called
requests for different mime-types sent to a particular action.
A container for responses available from the current controller for

def any(*args, &block)

def any(*args, &block)
  if args.any?
    args.each { |type| send(type, &block) }
  else
    custom(Mime::ALL, &block)
  end
end

def custom(mime_type, &block)

def custom(mime_type, &block)
  mime_type = Mime::Type.lookup(mime_type.to_s) unless mime_type.is_a?(Mime::Type)
  @order << mime_type
  @responses[mime_type] ||= block
end

def initialize(mimes)

def initialize(mimes)
  @order, @responses = [], {}
  mimes.each { |mime| send(mime) }
end

def negotiate_format(request)

def negotiate_format(request)
  @format = request.negotiate_mime(order)
end

def response

def response
  @responses.fetch(format, @responses[Mime::ALL])
end