From 0dd5433b98afb0411449a4fd45dd0f918126c4ec Mon Sep 17 00:00:00 2001
From: Ryan Bigg <radarlistener@gmail.com>
Date: Tue, 28 Dec 2010 14:13:43 +1000
Subject: Cover the inherited method from Rails::Railtie being used when
 I18n::Railtie is loaded.

---
 railties/guides/source/initialization.textile | 34 ++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

(limited to 'railties/guides/source/initialization.textile')

diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile
index 738d5cf71a..10937626af 100644
--- a/railties/guides/source/initialization.textile
+++ b/railties/guides/source/initialization.textile
@@ -723,7 +723,39 @@ This file is the first file that sets up configuration with these lines inside t
     config.i18n.fallbacks = ActiveSupport::OrderedOptions.new
 </ruby>
 
-The +config+ method here is defined on +Rails::Railtie+ and is defined like this:
+By inheriting from +Rails::Railtie+ the +Rails::Railtie#inherited+ method is called:
+
+<ruby>
+  def inherited(base)
+    unless base.abstract_railtie?
+      base.send(:include, Railtie::Configurable)
+      subclasses << base
+    end
+  end
+</ruby>
+
+This first checks if the Railtie that's inheriting it is a component of Rails itself:
+
+<ruby>
+ABSTRACT_RAILTIES = %w(Rails::Railtie Rails::Plugin Rails::Engine Rails::Application)
+
+...
+
+def abstract_railtie?
+  ABSTRACT_RAILTIES.include?(name)
+end
+</ruby>
+
+Because +I18n::Railtie+ isn't in this list, +abstract_railtie?+ returns +false+. Therefore the +Railtie::Configurable+ module is included into this class and the +subclasses+ method is called and +I18n::Railtie+ is added to this new array.
+
+<ruby>
+def subclasses
+  @subclasses ||= []
+end
+</ruby>
+
+
+The +config+ method used at the top of +I18n::Railtie+ is defined on +Rails::Railtie+ and is defined like this:
 
 <ruby>
   def config
-- 
cgit v1.2.3

