Skip to content

Commit

Permalink
Change documentation of metal anonymous class
Browse files Browse the repository at this point in the history
Make it clearer

[ci skip]
  • Loading branch information
lukaszx0 committed Aug 25, 2013
1 parent cb2d671 commit e9f06b2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions actionpack/lib/action_controller/base.rb
Expand Up @@ -3,11 +3,16 @@
require "action_controller/metal/params_wrapper" require "action_controller/metal/params_wrapper"


module ActionController module ActionController
# The <tt>metal</tt> anonymous class is simple workaround the ordering issues there are with modules. # The <tt>metal</tt> anonymous class was introduced to solve issue with including modules in <tt>ActionController::Base</tt>.
# They need to be included in specific order which makes it impossible for 3rd party libs (like ActiveRecord) # Modules needes to be included in particluar order. First wee need to have <tt>AbstractController::Rendering</tt> included,
# to hook up with its own functionality. Having anonymous super class type of Metal with <tt>AbstractController::Rendering</tt> # next we should include actuall implementation which would be for example <tt>ActionView::Rendering</tt> and after that
# included, allows us to include <tt>ActionView::Rendering</tt> (which implements <tt>AbstractController::Rendering</tt> interface) # <tt>ActionController::Rendering</tt>. This order must be preserved and as we want to have middle module included dynamicaly
# after the <tt>AbstractController::Rendering</tt> and before <tt>ActionController::Rendering</tt>. # <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 = Class.new(Metal) do metal = Class.new(Metal) do
include AbstractController::Rendering include AbstractController::Rendering
end end
Expand Down

0 comments on commit e9f06b2

Please sign in to comment.