aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/initialization.textile
diff options
context:
space:
mode:
authorRyan Bigg <radarlistener@gmail.com>2010-12-28 14:04:19 +1000
committerRyan Bigg <radarlistener@gmail.com>2010-12-28 14:04:19 +1000
commit6777b7a886440a1faa9e29fcfa57a73a28128f68 (patch)
tree56c375d8ac8acde26dcc1683d306146f5c527a34 /railties/guides/source/initialization.textile
parent7b7537317c02c37c894fc65ff1b685d9d247e87a (diff)
downloadrails-6777b7a886440a1faa9e29fcfa57a73a28128f68.tar.gz
rails-6777b7a886440a1faa9e29fcfa57a73a28128f68.tar.bz2
rails-6777b7a886440a1faa9e29fcfa57a73a28128f68.zip
Init guide: finish covering the process of the i18n_railtie.rb file.
Diffstat (limited to 'railties/guides/source/initialization.textile')
-rw-r--r--railties/guides/source/initialization.textile20
1 files changed, 20 insertions, 0 deletions
diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile
index ceee4639a2..738d5cf71a 100644
--- a/railties/guides/source/initialization.textile
+++ b/railties/guides/source/initialization.textile
@@ -850,6 +850,26 @@ The +on_load+ method here is provided by the +active_support/lazy_load_hooks+ fi
end
</ruby>
+The +@loaded+ variable here is a hash containing elements representing the different components of Rails that have been loaded at this stage. Currently, this hash is empty. So the +else+ is executed here, using the +@load_hooks+ variable defined in +active_support/lazy_load_hooks+:
+
+<ruby>
+ @load_hooks = Hash.new {|h,k| h[k] = [] }
+</ruby>
+
+This defines a new hash which has keys that default to empty arrays. This saves Rails from having to do something like this instead:
+
+<ruby>
+ @load_hooks[name] = []
+ @load_hooks[name] << [block, options]
+</ruby>
+
+The value added to this array here consists of the block and options passed to +after_initialize+.
+
+We'll see these +@load_hooks+ used later on in the initialization process.
+
+This rest of +i18n_railtie.rb+ defines the protected class methods +include_fallback_modules+, +init_fallbacks+ and +validate_fallbacks+.
+
+
**** REVIEW IS HERE ****
This defines two methods on the module itself by using the familiar +class << self+ syntax. This allows you to call them as if they were class methods: +ActiveSupport.on_load_all+ and +ActiveSupport.load_all!+ respectively. The first method simply adds loading hooks to save them up for loading later on when +load_all!+ is called. By +call+'ing the block, the classes will be loaded. (NOTE: kind of guessing, I feel 55% about this).