aboutsummaryrefslogtreecommitdiffstats
path: root/railties/guides/source/active_support_core_extensions.textile
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-03-16 23:38:08 +0100
committerXavier Noria <fxn@hashref.com>2010-03-16 23:38:08 +0100
commitb6edffa640674b10c81bf2905d455cafb52c068f (patch)
treebde08c6a4b0ec6476c5ca75184cb957892554fd8 /railties/guides/source/active_support_core_extensions.textile
parentf9edf89d576e5b3558d9704df89a5743f851fc97 (diff)
downloadrails-b6edffa640674b10c81bf2905d455cafb52c068f.tar.gz
rails-b6edffa640674b10c81bf2905d455cafb52c068f.tar.bz2
rails-b6edffa640674b10c81bf2905d455cafb52c068f.zip
AS guide: completes section about loading AS core extensions within a Rails application
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r--railties/guides/source/active_support_core_extensions.textile14
1 files changed, 10 insertions, 4 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index b4bf148cc2..db28e07642 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -8,6 +8,8 @@ endprologue.
h3. How to Load Core Extensions
+h4. Stand-Alone Active Support
+
In order to have a near zero default footprint, Active Support does not load anything by default. It is broken in small pieces so that you may load just what you need, and also has some convenience entry points to load related extensions in one shot, even everything.
Thus, after a simple require like:
@@ -18,7 +20,7 @@ require 'active_support'
objects do not even respond to +blank?+, let's see how to load its definition.
-h4. Cherry-picking a Definition
+h5. Cherry-picking a Definition
The most lightweight way to get +blank?+ is to cherry-pick the file that defines it.
@@ -34,7 +36,7 @@ require 'active_support/core_ext/object/blank'
Active Support has been carefully revised so that cherry-picking a file loads only strictly needed dependencies, if any.
-h4. Loading Grouped Core Extensions
+h5. Loading Grouped Core Extensions
The next level is to simply load all extensions to +Object+. As a rule of thumb, extensions to +SomeClass+ are available in one shot by loading +active_support/core_ext/some_class+.
@@ -44,7 +46,7 @@ Thus, if that would do, to have +blank?+ available we could just load all extens
require 'active_support/core_ext/object'
</ruby>
-h4. Loading All Core Extensions
+h5. Loading All Core Extensions
You may prefer just to load all core extensions, there is a file for that:
@@ -52,7 +54,7 @@ You may prefer just to load all core extensions, there is a file for that:
require 'active_support/core_ext'
</ruby>
-h4. Loading All Active Support
+h5. Loading All Active Support
And finally, if you want to have all Active Support available just issue:
@@ -62,6 +64,10 @@ require 'active_support/all'
That does not even put the entire Active Support in memory upfront indeed, some stuff is configured via +autoload+, so it is only loaded if used.
+h4. Active Support Within a Ruby on Rails Application
+
+A Ruby on Rails application loads all Active Support unless +config.active_support.bare+ is true. In that case, the application will only load what the framework itself cherry-picks for its own needs, and can still cherry-pick itself at any granularity level, as explained in the previous section.
+
h3. Extensions to All Objects
h4. +blank?+ and +present?+