Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change documentation of metal anonymous class

Make it clearer

[ci skip]
  • Loading branch information...
commit e9f06b2ac151be1957395076f55cbfa9979bf2a5 1 parent cb2d671
@strzalek strzalek authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 actionpack/lib/action_controller/base.rb
15 actionpack/lib/action_controller/base.rb
@@ -3,11 +3,16 @@
require "action_controller/metal/params_wrapper"
module ActionController
- # The <tt>metal</tt> anonymous class is simple workaround the ordering issues there are with modules.
- # They need to be included in specific order which makes it impossible for 3rd party libs (like ActiveRecord)
- # to hook up with its own functionality. Having anonymous super class type of Metal with <tt>AbstractController::Rendering</tt>
- # included, allows us to include <tt>ActionView::Rendering</tt> (which implements <tt>AbstractController::Rendering</tt> interface)
- # after the <tt>AbstractController::Rendering</tt> and before <tt>ActionController::Rendering</tt>.
+ # The <tt>metal</tt> anonymous class was introduced to solve issue with including modules in <tt>ActionController::Base</tt>.
+ # Modules needes to be included in particluar order. First wee need to have <tt>AbstractController::Rendering</tt> included,
+ # next we should include actuall implementation which would be for example <tt>ActionView::Rendering</tt> and after that
+ # <tt>ActionController::Rendering</tt>. This order must be preserved and as we want to have middle module included dynamicaly
+ # <tt>metal</tt> class was introduced. It has <tt>AbstractController::Rendering</tt> included and is parent class of
+ # <tt>ActionController::Base</tt> which includes <tt>ActionController::Rendering</tt>. If we include <tt>ActionView::Rendering</tt>
+ # beetween them to perserve the required order, we can simply do this by:
+ #
+ # ActionController::Base.superclass.send(:include, ActionView::Rendering)
+ #
metal = do
include AbstractController::Rendering
Please sign in to comment.
Something went wrong with that request. Please try again.