diff options
author | José Valim <jose.valim@gmail.com> | 2009-12-21 11:21:27 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-12-21 11:21:27 +0100 |
commit | 5f34421c77b4cd873baadbbca877a93de5a4d602 (patch) | |
tree | 8182bb1c53864ab06079e14116a61d66e9617f7d /activesupport/lib/active_support/dependencies/autoload.rb | |
parent | cf7b94c013d4e824433a018001474e71ddd81a99 (diff) | |
parent | f09ad263cabe2e781c1994b85375fee8deba4317 (diff) | |
download | rails-5f34421c77b4cd873baadbbca877a93de5a4d602.tar.gz rails-5f34421c77b4cd873baadbbca877a93de5a4d602.tar.bz2 rails-5f34421c77b4cd873baadbbca877a93de5a4d602.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'activesupport/lib/active_support/dependencies/autoload.rb')
-rw-r--r-- | activesupport/lib/active_support/dependencies/autoload.rb | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/dependencies/autoload.rb b/activesupport/lib/active_support/dependencies/autoload.rb index 973875f895..96ab04c61a 100644 --- a/activesupport/lib/active_support/dependencies/autoload.rb +++ b/activesupport/lib/active_support/dependencies/autoload.rb @@ -2,16 +2,18 @@ require "active_support/inflector/methods" module ActiveSupport module Autoload - @@autoloads = {} @@under_path = nil @@at_path = nil + @@autoload_defer = false def autoload(const_name, path = @@at_path) full = [self.name, @@under_path, const_name.to_s, path].compact.join("::") location = path || Inflector.underscore(full) - @@autoloads[const_name] = location + unless @@autoload_defer + @@autoloads[const_name] = location + end super const_name, location end @@ -29,9 +31,19 @@ module ActiveSupport @@at_path = old_path end + def deferrable + old_defer, @@autoload_defer = @@autoload_defer, true + yield + ensure + @@autoload_defer = old_defer + end + def self.eager_autoload! - @@autoloads.values.each {|file| require file } + @@autoloads.values.each { |file| require file } end + def autoloads + @@autoloads + end end -end
\ No newline at end of file +end |