diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-12 18:41:26 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-12 18:41:26 -0600 |
commit | 018dafe574d370165547516ffef43394e11ab4da (patch) | |
tree | 6ad2359b8f00dabee5e1fd46bebb59fc72530f36 | |
parent | ee395fe626760e897abd9e881b54d3cc3f407d31 (diff) | |
download | rails-018dafe574d370165547516ffef43394e11ab4da.tar.gz rails-018dafe574d370165547516ffef43394e11ab4da.tar.bz2 rails-018dafe574d370165547516ffef43394e11ab4da.zip |
Allow autoloads to opt out of eager loading
-rw-r--r-- | actionpack/lib/action_controller/deprecated/integration_test.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch.rb | 49 | ||||
-rwxr-xr-x | actionpack/lib/action_dispatch/http/request.rb | 3 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/test_case.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 1 | ||||
-rw-r--r-- | activesupport/lib/active_support/dependencies/autoload.rb | 20 |
7 files changed, 47 insertions, 36 deletions
diff --git a/actionpack/lib/action_controller/deprecated/integration_test.rb b/actionpack/lib/action_controller/deprecated/integration_test.rb index 05c8c0f156..86336b6bc4 100644 --- a/actionpack/lib/action_controller/deprecated/integration_test.rb +++ b/actionpack/lib/action_controller/deprecated/integration_test.rb @@ -1,4 +1,2 @@ -require "action_dispatch/testing/integration" - ActionController::Integration = ActionDispatch::Integration ActionController::IntegrationTest = ActionDispatch::IntegrationTest diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 14cd0dc7e0..398ea52495 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -1,7 +1,6 @@ require 'active_support/test_case' require 'rack/session/abstract/id' require 'action_controller/metal/testing' -require 'action_dispatch/test_case' module ActionController class TestRequest < ActionDispatch::TestRequest #:nodoc: diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index e21dbc59cc..d1c191d652 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -30,38 +30,47 @@ end module ActionDispatch extend ActiveSupport::Autoload - autoload_under "http" do + autoload_under 'http' do autoload :Request autoload :Response autoload :StatusCodes autoload :Utils end - autoload_under "middleware" do - autoload :Callbacks - autoload :ParamsParser - autoload :Rescue - autoload :ShowExceptions - autoload :Static - autoload :StringCoercion - end + deferrable do + autoload_under 'middleware' do + autoload :Callbacks + autoload :ParamsParser + autoload :Rescue + autoload :ShowExceptions + autoload :Static + autoload :StringCoercion + end - autoload :MiddlewareStack, 'action_dispatch/middleware/stack' - autoload :Routing + autoload :MiddlewareStack, 'action_dispatch/middleware/stack' + autoload :Routing - autoload :HTML, 'action_controller/vendor/html-scanner' + module Http + autoload :Headers, 'action_dispatch/http/headers' + end - module Http - extend ActiveSupport::Autoload + module Session + autoload :AbstractStore, 'action_dispatch/middleware/session/abstract_store' + autoload :CookieStore, 'action_dispatch/middleware/session/cookie_store' + autoload :MemCacheStore, 'action_dispatch/middleware/session/mem_cache_store' + end - autoload :Headers + autoload_under 'testing' do + autoload :Assertions + autoload :Integration + autoload :PerformanceTest + autoload :TestProcess + autoload :TestRequest + autoload :TestResponse + end end - module Session - autoload :AbstractStore, 'action_dispatch/middleware/session/abstract_store' - autoload :CookieStore, 'action_dispatch/middleware/session/cookie_store' - autoload :MemCacheStore, 'action_dispatch/middleware/session/mem_cache_store' - end + autoload :HTML, 'action_controller/vendor/html-scanner' end autoload :Mime, 'action_dispatch/http/mime_type' diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 6a52854961..7d1f5a4504 100755 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -6,6 +6,7 @@ require 'active_support/memoizable' require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/hash/indifferent_access' require 'active_support/core_ext/string/access' +require 'action_dispatch/http/headers' module ActionDispatch class Request < Rack::Request @@ -117,7 +118,7 @@ module ActionDispatch end end end - + def if_modified_since if since = env['HTTP_IF_MODIFIED_SINCE'] Time.rfc2822(since) rescue nil diff --git a/actionpack/lib/action_dispatch/test_case.rb b/actionpack/lib/action_dispatch/test_case.rb deleted file mode 100644 index 0b3dfaae79..0000000000 --- a/actionpack/lib/action_dispatch/test_case.rb +++ /dev/null @@ -1,7 +0,0 @@ -require "rack/test" -require "action_dispatch/testing/assertions" -require "action_dispatch/testing/integration" -require "action_dispatch/testing/performance_test" -require "action_dispatch/testing/test_request" -require "action_dispatch/testing/test_response" -require "action_dispatch/testing/integration"
\ No newline at end of file diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index 76021dc059..5c127dfe37 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -2,7 +2,6 @@ require 'stringio' require 'uri' require 'active_support/test_case' require 'active_support/core_ext/object/metaclass' -require 'action_dispatch/testing/test_process' require 'rack/test' module ActionDispatch 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 |