diff options
author | Ryan Bigg <radarlistener@gmail.com> | 2010-12-28 14:13:43 +1000 |
---|---|---|
committer | Ryan Bigg <radarlistener@gmail.com> | 2010-12-28 14:13:43 +1000 |
commit | 0dd5433b98afb0411449a4fd45dd0f918126c4ec (patch) | |
tree | 62b1d5ec63c6f1bc1e7be37c71d36bba8877a8fa | |
parent | 6777b7a886440a1faa9e29fcfa57a73a28128f68 (diff) | |
download | rails-0dd5433b98afb0411449a4fd45dd0f918126c4ec.tar.gz rails-0dd5433b98afb0411449a4fd45dd0f918126c4ec.tar.bz2 rails-0dd5433b98afb0411449a4fd45dd0f918126c4ec.zip |
Cover the inherited method from Rails::Railtie being used when I18n::Railtie is loaded.
-rw-r--r-- | railties/guides/source/initialization.textile | 34 |
1 files changed, 33 insertions, 1 deletions
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 |