Permalink
Browse files

Added documentation for the ActionController::MimeResponds::Collector…

… class.
  • Loading branch information...
1 parent 64cd57a commit 4cb71eaf463bb6a12edd1aaf222e9f1e3269bea7 @MarkMT MarkMT committed Mar 13, 2012
Showing with 24 additions and 1 deletion.
  1. +24 −1 actionpack/lib/action_controller/metal/mime_responds.rb
View
25 actionpack/lib/action_controller/metal/mime_responds.rb
@@ -279,7 +279,30 @@ def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc:
end
end
- class Collector #:nodoc:
+ # A container of responses available for requests with different mime-types
+ # sent to the current controller action.
+ #
+ # The public controller methods +respond_with+ and +respond_to+ may be called
+ # with a block that is used to define responses to different mime-types, e.g.
+ # for +respond_to+ :
+ #
+ # respond_to do |format|
+ # format.html
+ # format.xml { render :xml => @people.to_xml }
+ # end
+ #
+ # In this usage, the argument passed to the block (+format+ above) is an
+ # instance of the ActionController::MimeResponds::Collector class. This
+ # object serves as a container in which available responses can be stored by
+ # calling any of the dynamically generated, mime-type-specific methods such
+ # as +html+, +xml+ etc on the Collector. Each response is represented by a
+ # corresponding block if present.
+ #
+ # A subsequent call to #negotiate_format(request) will enable the Collector
+ # to determine which specific mime-type it should respond with for the current
+ # request, with this response then being accessible by calling #response.
+ #
+ class Collector
include AbstractController::Collector
attr_accessor :order, :format

0 comments on commit 4cb71ea

Please sign in to comment.