Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use autoload instead of explicit requires for ActionController

commit 31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f 1 parent 6de1060
@josh josh authored
Showing with 73 additions and 96 deletions.
  1. +56 −40 actionpack/lib/action_controller.rb
  2. +7 −7 actionpack/lib/action_controller/base.rb
  3. +8 −10 actionpack/lib/action_controller/caching.rb
  4. +0 −1  actionpack/lib/action_controller/cgi_process.rb
  5. +0 −4 actionpack/lib/action_controller/integration.rb
  6. +0 −1  actionpack/lib/action_controller/performance_test.rb
  7. +0 −1  actionpack/lib/action_controller/rack_process.rb
  8. +0 −1  actionpack/lib/action_controller/request_profiler.rb
  9. +0 −4 actionpack/lib/action_controller/resources.rb
  10. +0 −1  actionpack/lib/action_controller/routing.rb
  11. +2 −0  actionpack/lib/action_controller/routing/route_set.rb
  12. +0 −7 actionpack/lib/action_controller/session_management.rb
  13. +0 −2  actionpack/lib/action_view/test_case.rb
  14. +0 −1  actionpack/test/activerecord/active_record_store_test.rb
  15. +0 −1  actionpack/test/controller/cgi_test.rb
  16. +0 −2  actionpack/test/controller/dispatcher_test.rb
  17. +0 −2  actionpack/test/controller/integration_test.rb
  18. +0 −2  actionpack/test/controller/integration_upload_test.rb
  19. +0 −1  actionpack/test/controller/rack_test.rb
  20. +0 −1  actionpack/test/controller/request_test.rb
  21. +0 −1  actionpack/test/controller/routing_test.rb
  22. +0 −3  actionpack/test/controller/session/cookie_store_test.rb
  23. +0 −3  actionpack/test/controller/session/mem_cache_store_test.rb
View
96 actionpack/lib/action_controller.rb
@@ -32,47 +32,63 @@
end
$:.unshift "#{File.dirname(__FILE__)}/action_controller/vendor/html-scanner"
-require 'action_controller/vendor/rack'
-require 'action_controller/base'
-require 'action_controller/request'
-require 'action_controller/rescue'
-require 'action_controller/benchmarking'
-require 'action_controller/flash'
-require 'action_controller/filters'
-require 'action_controller/layout'
-require 'action_controller/mime_responds'
-require 'action_controller/helpers'
-require 'action_controller/cookies'
-require 'action_controller/cgi_process'
-require 'action_controller/caching'
-require 'action_controller/verification'
-require 'action_controller/streaming'
-require 'action_controller/session_management'
-require 'action_controller/http_authentication'
-require 'action_controller/rack_process'
-require 'action_controller/record_identifier'
-require 'action_controller/request_forgery_protection'
-require 'action_controller/headers'
-require 'action_controller/translation'
+module ActionController
+ # TODO: Review explicit to see if they will automatically be handled by
+ # the initilizer if they are really needed.
+ def self.load_all!
+ [Base, CgiRequest, CgiResponse, RackRequest, RackRequest, Http::Headers, UrlRewriter, UrlWriter]
+ end
-require 'action_view'
+ autoload :AbstractRequest, 'action_controller/request'
+ autoload :AbstractResponse, 'action_controller/response'
+ autoload :Base, 'action_controller/base'
+ autoload :Benchmarking, 'action_controller/benchmarking'
+ autoload :Caching, 'action_controller/caching'
+ autoload :CgiRequest, 'action_controller/cgi_process'
+ autoload :CgiResponse, 'action_controller/cgi_process'
+ autoload :Cookies, 'action_controller/cookies'
+ autoload :Dispatcher, 'action_controller/dispatcher'
+ autoload :Filters, 'action_controller/filters'
+ autoload :Flash, 'action_controller/flash'
+ autoload :Helpers, 'action_controller/helpers'
+ autoload :HttpAuthentication, 'action_controller/http_authentication'
+ autoload :IntegrationTest, 'action_controller/integration'
+ autoload :Layout, 'action_controller/layout'
+ autoload :MimeResponds, 'action_controller/mime_responds'
+ autoload :PolymorphicRoutes, 'action_controller/polymorphic_routes'
+ autoload :RackRequest, 'action_controller/rack_process'
+ autoload :RackResponse, 'action_controller/rack_process'
+ autoload :RecordIdentifier, 'action_controller/record_identifier'
+ autoload :RequestForgeryProtection, 'action_controller/request_forgery_protection'
+ autoload :Rescue, 'action_controller/rescue'
+ autoload :Resources, 'action_controller/resources'
+ autoload :Routing, 'action_controller/routing'
+ autoload :SessionManagement, 'action_controller/session_management'
+ autoload :StatusCodes, 'action_controller/status_codes'
+ autoload :Streaming, 'action_controller/streaming'
+ autoload :TestCase, 'action_controller/test_case'
+ autoload :TestProcess, 'action_controller/test_process'
+ autoload :Translation, 'action_controller/translation'
+ autoload :UrlRewriter, 'action_controller/url_rewriter'
+ autoload :UrlWriter, 'action_controller/url_rewriter'
+ autoload :Verification, 'action_controller/verification'
-ActionController::Base.class_eval do
- include ActionController::Flash
- include ActionController::Filters
- include ActionController::Layout
- include ActionController::Benchmarking
- include ActionController::Rescue
- include ActionController::MimeResponds
- include ActionController::Helpers
- include ActionController::Cookies
- include ActionController::Caching
- include ActionController::Verification
- include ActionController::Streaming
- include ActionController::SessionManagement
- include ActionController::HttpAuthentication::Basic::ControllerMethods
- include ActionController::RecordIdentifier
- include ActionController::RequestForgeryProtection
- include ActionController::Translation
+ module Http
+ autoload :Headers, 'action_controller/headers'
+ end
end
+
+class CGI
+ class Session
+ autoload :ActiveRecordStore, 'action_controller/session/active_record_store'
+ autoload :CookieStore, 'action_controller/session/cookie_store'
+ autoload :DRbStore, 'action_controller/session/drb_store'
+ autoload :MemCacheStore, 'action_controller/session/mem_cache_store'
+ end
+end
+
+autoload :Mime, 'action_controller/mime_type'
+autoload :Rack, 'action_controller/vendor/rack'
+
+ActionController.load_all!
View
14 actionpack/lib/action_controller/base.rb
@@ -1,10 +1,3 @@
-require 'action_controller/mime_type'
-require 'action_controller/request'
-require 'action_controller/response'
-require 'action_controller/routing'
-require 'action_controller/resources'
-require 'action_controller/url_rewriter'
-require 'action_controller/status_codes'
require 'action_view'
require 'drb'
require 'set'
@@ -1332,4 +1325,11 @@ def process_cleanup
close_session
end
end
+
+ Base.class_eval do
+ include Flash, Filters, Layout, Benchmarking, Rescue, MimeResponds, Helpers
+ include Cookies, Caching, Verification, Streaming
+ include SessionManagement, HttpAuthentication::Basic::ControllerMethods
+ include RecordIdentifier, RequestForgeryProtection, Translation
+ end
end
View
18 actionpack/lib/action_controller/caching.rb
@@ -2,13 +2,6 @@
require 'uri'
require 'set'
-require 'action_controller/caching/pages'
-require 'action_controller/caching/actions'
-require 'action_controller/caching/sql_cache'
-require 'action_controller/caching/sweeping'
-require 'action_controller/caching/fragments'
-
-
module ActionController #:nodoc:
# Caching is a cheap way of speeding up slow applications by keeping the result of calculations, renderings, and database calls
# around for subsequent requests. Action Controller affords you three approaches in varying levels of granularity: Page, Action, Fragment.
@@ -31,6 +24,12 @@ module ActionController #:nodoc:
# ActionController::Base.cache_store = :mem_cache_store, "localhost"
# ActionController::Base.cache_store = MyOwnStore.new("parameter")
module Caching
+ autoload :Actions, 'action_controller/caching/actions'
+ autoload :Fragments, 'action_controller/caching/fragments'
+ autoload :Pages, 'action_controller/caching/pages'
+ autoload :SqlCache, 'action_controller/caching/sql_cache'
+ autoload :Sweeping, 'action_controller/caching/sweeping'
+
def self.included(base) #:nodoc:
base.class_eval do
@@cache_store = nil
@@ -63,10 +62,9 @@ def cache(key, options = {}, &block)
end
end
-
- private
+ private
def cache_configured?
self.class.cache_configured?
end
end
-end
+end
View
1  actionpack/lib/action_controller/cgi_process.rb
@@ -1,5 +1,4 @@
require 'action_controller/cgi_ext'
-require 'action_controller/session/cookie_store'
module ActionController #:nodoc:
class Base
View
4 actionpack/lib/action_controller/integration.rb
@@ -1,7 +1,3 @@
-require 'action_controller/test_case'
-require 'action_controller/dispatcher'
-require 'action_controller/test_process'
-
require 'stringio'
require 'uri'
View
1  actionpack/lib/action_controller/performance_test.rb
@@ -1,4 +1,3 @@
-require 'action_controller/integration'
require 'active_support/testing/performance'
require 'active_support/testing/default'
View
1  actionpack/lib/action_controller/rack_process.rb
@@ -1,5 +1,4 @@
require 'action_controller/cgi_ext'
-require 'action_controller/session/cookie_store'
module ActionController #:nodoc:
class RackRequest < AbstractRequest #:nodoc:
View
1  actionpack/lib/action_controller/request_profiler.rb
@@ -1,5 +1,4 @@
require 'optparse'
-require 'action_controller/integration'
module ActionController
class RequestProfiler
View
4 actionpack/lib/action_controller/resources.rb
@@ -669,7 +669,3 @@ def action_options_for(action, resource, method = nil)
end
end
end
-
-class ActionController::Routing::RouteSet::Mapper
- include ActionController::Resources
-end
View
1  actionpack/lib/action_controller/routing.rb
@@ -1,6 +1,5 @@
require 'cgi'
require 'uri'
-require 'action_controller/polymorphic_routes'
require 'action_controller/routing/optimisations'
require 'action_controller/routing/routing_ext'
require 'action_controller/routing/route'
View
2  actionpack/lib/action_controller/routing/route_set.rb
@@ -7,6 +7,8 @@ class RouteSet #:nodoc:
# Mapper instances have relatively few instance methods, in order to avoid
# clashes with named routes.
class Mapper #:doc:
+ include ActionController::Resources
+
def initialize(set) #:nodoc:
@set = set
end
View
7 actionpack/lib/action_controller/session_management.rb
@@ -1,10 +1,3 @@
-require 'action_controller/session/cookie_store'
-require 'action_controller/session/drb_store'
-require 'action_controller/session/mem_cache_store'
-if Object.const_defined?(:ActiveRecord)
- require 'action_controller/session/active_record_store'
-end
-
module ActionController #:nodoc:
module SessionManagement #:nodoc:
def self.included(base)
View
2  actionpack/lib/action_view/test_case.rb
@@ -1,5 +1,3 @@
-require 'action_controller/test_case'
-
module ActionView
class TestCase < ActiveSupport::TestCase
include ActionController::TestCase::Assertions
View
1  actionpack/test/activerecord/active_record_store_test.rb
@@ -1,7 +1,6 @@
# These tests exercise CGI::Session::ActiveRecordStore, so you're going to
# need AR in a sibling directory to AP and have SQLite installed.
require 'active_record_unit'
-require 'action_controller/session/active_record_store'
module CommonActiveRecordStoreTests
def test_basics
View
1  actionpack/test/controller/cgi_test.rb
@@ -1,5 +1,4 @@
require 'abstract_unit'
-require 'action_controller/cgi_process'
class BaseCgiTest < Test::Unit::TestCase
def setup
View
2  actionpack/test/controller/dispatcher_test.rb
@@ -2,8 +2,6 @@
uses_mocha 'dispatcher tests' do
-require 'action_controller/dispatcher'
-
class DispatcherTest < Test::Unit::TestCase
Dispatcher = ActionController::Dispatcher
View
2  actionpack/test/controller/integration_test.rb
@@ -1,6 +1,4 @@
require 'abstract_unit'
-require 'action_controller/integration'
-require 'action_controller/routing'
uses_mocha 'integration' do
View
2  actionpack/test/controller/integration_upload_test.rb
@@ -1,6 +1,4 @@
require 'abstract_unit'
-require 'action_controller/integration'
-require 'action_controller/routing'
unless defined? ApplicationController
class ApplicationController < ActionController::Base
View
1  actionpack/test/controller/rack_test.rb
@@ -1,5 +1,4 @@
require 'abstract_unit'
-require 'action_controller/rack_process'
class BaseRackTest < Test::Unit::TestCase
def setup
View
1  actionpack/test/controller/request_test.rb
@@ -1,5 +1,4 @@
require 'abstract_unit'
-require 'action_controller/integration'
class RequestTest < ActiveSupport::TestCase
def setup
View
1  actionpack/test/controller/routing_test.rb
@@ -1,6 +1,5 @@
require 'abstract_unit'
require 'controller/fake_controllers'
-require 'action_controller/routing'
class MilestonesController < ActionController::Base
def index() head :ok end
View
3  actionpack/test/controller/session/cookie_store_test.rb
@@ -1,7 +1,4 @@
require 'abstract_unit'
-require 'action_controller/cgi_process'
-require 'action_controller/cgi_ext'
-
require 'stringio'
View
3  actionpack/test/controller/session/mem_cache_store_test.rb
@@ -1,7 +1,4 @@
require 'abstract_unit'
-require 'action_controller/cgi_process'
-require 'action_controller/cgi_ext'
-
class CGI::Session
def cache
Please sign in to comment.
Something went wrong with that request. Please try again.