diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-22 17:27:37 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-22 17:27:37 -0600 |
commit | ace20bd25e3818b7f29c222643dd445c48b36425 (patch) | |
tree | d8bdc5e685f6d4e56e7f6c6e1f0a27fdad8b20ed | |
parent | b1aee9f4eebdae4fad38572359649c097c731b77 (diff) | |
download | rails-ace20bd25e3818b7f29c222643dd445c48b36425.tar.gz rails-ace20bd25e3818b7f29c222643dd445c48b36425.tar.bz2 rails-ace20bd25e3818b7f29c222643dd445c48b36425.zip |
Flip deferrable autoload convention
-rw-r--r-- | actionmailer/lib/action_mailer.rb | 31 | ||||
-rw-r--r-- | actionpack/lib/abstract_controller.rb | 16 | ||||
-rw-r--r-- | actionpack/lib/action_controller.rb | 112 | ||||
-rw-r--r-- | actionpack/lib/action_controller/caching.rb | 12 | ||||
-rw-r--r-- | actionpack/lib/action_controller/vendor/html-scanner.rb | 26 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch.rb | 60 | ||||
-rw-r--r-- | actionpack/lib/action_view.rb | 41 | ||||
-rw-r--r-- | actionpack/lib/action_view/template.rb | 14 | ||||
-rw-r--r-- | activemodel/lib/active_model.rb | 42 | ||||
-rw-r--r-- | activerecord/lib/active_record.rb | 116 | ||||
-rw-r--r-- | activeresource/lib/active_resource.rb | 18 | ||||
-rw-r--r-- | activesupport/lib/active_support.rb | 53 | ||||
-rw-r--r-- | activesupport/lib/active_support/dependencies/autoload.rb | 10 |
13 files changed, 290 insertions, 261 deletions
diff --git a/actionmailer/lib/action_mailer.rb b/actionmailer/lib/action_mailer.rb index f439eb175c..6539451bea 100644 --- a/actionmailer/lib/action_mailer.rb +++ b/actionmailer/lib/action_mailer.rb @@ -30,29 +30,34 @@ require 'action_view' module ActionMailer extend ::ActiveSupport::Autoload - autoload :AdvAttrAccessor - autoload :DeprecatedBody - autoload :Base - autoload :DeliveryMethod - autoload :MailHelper - autoload :Part - autoload :PartContainer - autoload :Quoting - autoload :TestHelper - autoload :Utils + eager_autoload do + autoload :AdvAttrAccessor + autoload :DeprecatedBody + autoload :Base + autoload :DeliveryMethod + autoload :MailHelper + autoload :Part + autoload :PartContainer + autoload :Quoting + autoload :TestHelper + autoload :Utils + end end module Text extend ActiveSupport::Autoload - autoload :Format, 'action_mailer/vendor/text_format' + eager_autoload do + autoload :Format, 'action_mailer/vendor/text_format' + end end module Net extend ActiveSupport::Autoload - autoload :SMTP + eager_autoload do + autoload :SMTP + end end - require 'action_mailer/vendor/tmail' diff --git a/actionpack/lib/abstract_controller.rb b/actionpack/lib/abstract_controller.rb index c15a1da98a..237ab577ba 100644 --- a/actionpack/lib/abstract_controller.rb +++ b/actionpack/lib/abstract_controller.rb @@ -8,13 +8,11 @@ require 'active_support/core_ext/module/delegation' module AbstractController extend ActiveSupport::Autoload - deferrable do - autoload :Base - autoload :Callbacks - autoload :Helpers - autoload :Layouts - autoload :LocalizedCache - autoload :Logger - autoload :Rendering - end + autoload :Base + autoload :Callbacks + autoload :Helpers + autoload :Layouts + autoload :LocalizedCache + autoload :Logger + autoload :Rendering end diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb index 8b3a444cda..26a85d4de8 100644 --- a/actionpack/lib/action_controller.rb +++ b/actionpack/lib/action_controller.rb @@ -5,66 +5,66 @@ require 'active_support/ruby/shim' module ActionController extend ActiveSupport::Autoload - deferrable do - autoload :Base - autoload :Caching - autoload :PolymorphicRoutes - autoload :Translation - autoload :Metal - autoload :Middleware + autoload :Base + autoload :Caching + autoload :PolymorphicRoutes + autoload :Translation + autoload :Metal + autoload :Middleware - autoload_under "metal" do - autoload :Benchmarking - autoload :ConditionalGet - autoload :Configuration - autoload :Head - autoload :Helpers - autoload :HideActions - autoload :Layouts - autoload :Logger - autoload :MimeResponds - autoload :RackDelegation - autoload :Compatibility - autoload :Redirecting - autoload :Rendering - autoload :Renderers - autoload :Rescue - autoload :Responder - autoload :SessionManagement - autoload :UrlFor - autoload :Verification - autoload :Flash - autoload :RequestForgeryProtection - autoload :Streaming - autoload :HttpAuthentication - autoload :FilterParameterLogging - autoload :Cookies - end - - autoload :Dispatcher, 'action_controller/dispatch/dispatcher' - autoload :PerformanceTest, 'action_controller/deprecated/performance_test' - autoload :Routing, 'action_controller/deprecated' - autoload :Integration, 'action_controller/deprecated/integration_test' - autoload :IntegrationTest, 'action_controller/deprecated/integration_test' + autoload_under "metal" do + autoload :Benchmarking + autoload :ConditionalGet + autoload :Configuration + autoload :Head + autoload :Helpers + autoload :HideActions + autoload :Layouts + autoload :Logger + autoload :MimeResponds + autoload :RackDelegation + autoload :Compatibility + autoload :Redirecting + autoload :Rendering + autoload :Renderers + autoload :Rescue + autoload :Responder + autoload :SessionManagement + autoload :UrlFor + autoload :Verification + autoload :Flash + autoload :RequestForgeryProtection + autoload :Streaming + autoload :HttpAuthentication + autoload :FilterParameterLogging + autoload :Cookies end - autoload :RecordIdentifier - autoload :UrlRewriter - autoload :UrlWriter, 'action_controller/url_rewriter' + autoload :Dispatcher, 'action_controller/dispatch/dispatcher' + autoload :PerformanceTest, 'action_controller/deprecated/performance_test' + autoload :Routing, 'action_controller/deprecated' + autoload :Integration, 'action_controller/deprecated/integration_test' + autoload :IntegrationTest, 'action_controller/deprecated/integration_test' - # TODO: Don't autoload exceptions, setup explicit - # requires for files that need them - autoload_at "action_controller/metal/exceptions" do - autoload :ActionControllerError - autoload :RenderError - autoload :RoutingError - autoload :MethodNotAllowed - autoload :NotImplemented - autoload :UnknownController - autoload :MissingFile - autoload :RenderError - autoload :SessionOverflowError - autoload :UnknownHttpMethod + eager_autoload do + autoload :RecordIdentifier + autoload :UrlRewriter + autoload :UrlWriter, 'action_controller/url_rewriter' + + # TODO: Don't autoload exceptions, setup explicit + # requires for files that need them + autoload_at "action_controller/metal/exceptions" do + autoload :ActionControllerError + autoload :RenderError + autoload :RoutingError + autoload :MethodNotAllowed + autoload :NotImplemented + autoload :UnknownController + autoload :MissingFile + autoload :RenderError + autoload :SessionOverflowError + autoload :UnknownHttpMethod + end end end diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index ad357cceda..d784138ebe 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -32,11 +32,13 @@ module ActionController #:nodoc: extend ActiveSupport::Concern extend ActiveSupport::Autoload - autoload :Actions - autoload :Fragments - autoload :Pages - autoload :Sweeper, 'action_controller/caching/sweeping' - autoload :Sweeping, 'action_controller/caching/sweeping' + eager_autoload do + autoload :Actions + autoload :Fragments + autoload :Pages + autoload :Sweeper, 'action_controller/caching/sweeping' + autoload :Sweeping, 'action_controller/caching/sweeping' + end included do @@cache_store = nil diff --git a/actionpack/lib/action_controller/vendor/html-scanner.rb b/actionpack/lib/action_controller/vendor/html-scanner.rb index 2cb20ddd05..879b31e60e 100644 --- a/actionpack/lib/action_controller/vendor/html-scanner.rb +++ b/actionpack/lib/action_controller/vendor/html-scanner.rb @@ -3,16 +3,18 @@ $LOAD_PATH << "#{File.dirname(__FILE__)}/html-scanner" module HTML extend ActiveSupport::Autoload - autoload :CDATA, 'html/node' - autoload :Document, 'html/document' - autoload :FullSanitizer, 'html/sanitizer' - autoload :LinkSanitizer, 'html/sanitizer' - autoload :Node, 'html/node' - autoload :Sanitizer, 'html/sanitizer' - autoload :Selector, 'html/selector' - autoload :Tag, 'html/node' - autoload :Text, 'html/node' - autoload :Tokenizer, 'html/tokenizer' - autoload :Version, 'html/version' - autoload :WhiteListSanitizer, 'html/sanitizer' + eager_autoload do + autoload :CDATA, 'html/node' + autoload :Document, 'html/document' + autoload :FullSanitizer, 'html/sanitizer' + autoload :LinkSanitizer, 'html/sanitizer' + autoload :Node, 'html/node' + autoload :Sanitizer, 'html/sanitizer' + autoload :Selector, 'html/selector' + autoload :Tag, 'html/node' + autoload :Text, 'html/node' + autoload :Tokenizer, 'html/tokenizer' + autoload :Version, 'html/version' + autoload :WhiteListSanitizer, 'html/sanitizer' + end end diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb index 4e04e2a17c..fafcf7dc4e 100644 --- a/actionpack/lib/action_dispatch.rb +++ b/actionpack/lib/action_dispatch.rb @@ -34,42 +34,40 @@ end module ActionDispatch extend ActiveSupport::Autoload - deferrable do - autoload_under 'http' do - autoload :Request - autoload :Response - end + autoload_under 'http' do + autoload :Request + autoload :Response + end - autoload_under 'middleware' do - autoload :Callbacks - autoload :ParamsParser - autoload :Rescue - autoload :ShowExceptions - autoload :Static - autoload :StringCoercion - end + 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 - module Http - autoload :Headers, 'action_dispatch/http/headers' - end + module Http + autoload :Headers, 'action_dispatch/http/headers' + 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 + 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_under 'testing' do - autoload :Assertions - autoload :Integration - autoload :PerformanceTest - autoload :TestProcess - autoload :TestRequest - autoload :TestResponse - end + autoload_under 'testing' do + autoload :Assertions + autoload :Integration + autoload :PerformanceTest + autoload :TestProcess + autoload :TestRequest + autoload :TestResponse end end diff --git a/actionpack/lib/action_view.rb b/actionpack/lib/action_view.rb index aabe8c4314..f57f9ca229 100644 --- a/actionpack/lib/action_view.rb +++ b/actionpack/lib/action_view.rb @@ -31,27 +31,28 @@ require 'action_pack' module ActionView extend ActiveSupport::Autoload - autoload :Base - autoload :Context - autoload :Template - autoload :Helpers - autoload :SafeBuffer - - - autoload_under "render" do - autoload :Partials - autoload :Rendering + eager_autoload do + autoload :Base + autoload :Context + autoload :Template + autoload :Helpers + autoload :SafeBuffer + + autoload_under "render" do + autoload :Partials + autoload :Rendering + end + + autoload :MissingTemplate, 'action_view/base' + autoload :Resolver, 'action_view/template/resolver' + autoload :PathResolver, 'action_view/template/resolver' + autoload :PathSet, 'action_view/paths' + autoload :FileSystemResolverWithFallback, 'action_view/template/resolver' + + autoload :TemplateError, 'action_view/template/error' + autoload :TemplateHandler, 'action_view/template' + autoload :TemplateHandlers, 'action_view/template' end - - autoload :MissingTemplate, 'action_view/base' - autoload :Resolver, 'action_view/template/resolver' - autoload :PathResolver, 'action_view/template/resolver' - autoload :PathSet, 'action_view/paths' - autoload :FileSystemResolverWithFallback, 'action_view/template/resolver' - - autoload :TemplateError, 'action_view/template/error' - autoload :TemplateHandler, 'action_view/template' - autoload :TemplateHandlers, 'action_view/template' end require 'action_view/erb/util' diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb index 210ad508f5..a64ee09245 100644 --- a/actionpack/lib/action_view/template.rb +++ b/actionpack/lib/action_view/template.rb @@ -7,12 +7,14 @@ require "action_view/template/resolver" module ActionView class Template extend ActiveSupport::Autoload - - autoload :Error - autoload :Handler - autoload :Handlers - autoload :Text - + + eager_autoload do + autoload :Error + autoload :Handler + autoload :Handlers + autoload :Text + end + extend Template::Handlers attr_reader :source, :identifier, :handler, :mime_type, :formats, :details diff --git a/activemodel/lib/active_model.rb b/activemodel/lib/active_model.rb index e0de27b96d..46caa53219 100644 --- a/activemodel/lib/active_model.rb +++ b/activemodel/lib/active_model.rb @@ -29,29 +29,33 @@ require 'active_support' module ActiveModel extend ActiveSupport::Autoload - autoload :AttributeMethods - autoload :Conversion - autoload :DeprecatedErrorMethods - autoload :Dirty - autoload :Errors - autoload :Lint - autoload :Name, 'active_model/naming' - autoload :Naming - autoload :Observer, 'active_model/observing' - autoload :Observing - autoload :Serialization - autoload :StateMachine - autoload :Translation - autoload :Validations - autoload :ValidationsRepairHelper - autoload :Validator - autoload :VERSION + eager_autoload do + autoload :AttributeMethods + autoload :Conversion + autoload :DeprecatedErrorMethods + autoload :Dirty + autoload :Errors + autoload :Lint + autoload :Name, 'active_model/naming' + autoload :Naming + autoload :Observer, 'active_model/observing' + autoload :Observing + autoload :Serialization + autoload :StateMachine + autoload :Translation + autoload :Validations + autoload :ValidationsRepairHelper + autoload :Validator + autoload :VERSION + end module Serializers extend ActiveSupport::Autoload - autoload :JSON - autoload :Xml + eager_autoload do + autoload :JSON + autoload :Xml + end end end diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index 2376bbd04a..196b87c0ac 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -35,82 +35,94 @@ require 'arel' module ActiveRecord extend ActiveSupport::Autoload - autoload :VERSION - - autoload :ActiveRecordError, 'active_record/base' - autoload :ConnectionNotEstablished, 'active_record/base' - - autoload :Aggregations - autoload :AssociationPreload - autoload :Associations - autoload :AttributeMethods - autoload :Attributes - autoload :AutosaveAssociation - autoload :Relation - autoload :Base - autoload :Batches - autoload :Calculations - autoload :Callbacks - autoload :DynamicFinderMatch - autoload :DynamicScopeMatch - autoload :Migration - autoload :Migrator, 'active_record/migration' - autoload :NamedScope - autoload :NestedAttributes - autoload :Observer - autoload :QueryCache - autoload :Reflection - autoload :Schema - autoload :SchemaDumper - autoload :Serialization - autoload :SessionStore - autoload :StateMachine - autoload :Timestamp - autoload :Transactions - autoload :Types - autoload :Validations + eager_autoload do + autoload :VERSION + + autoload :ActiveRecordError, 'active_record/base' + autoload :ConnectionNotEstablished, 'active_record/base' + + autoload :Aggregations + autoload :AssociationPreload + autoload :Associations + autoload :AttributeMethods + autoload :Attributes + autoload :AutosaveAssociation + autoload :Relation + autoload :Base + autoload :Batches + autoload :Calculations + autoload :Callbacks + autoload :DynamicFinderMatch + autoload :DynamicScopeMatch + autoload :Migration + autoload :Migrator, 'active_record/migration' + autoload :NamedScope + autoload :NestedAttributes + autoload :Observer + autoload :QueryCache + autoload :Reflection + autoload :Schema + autoload :SchemaDumper + autoload :Serialization + autoload :SessionStore + autoload :StateMachine + autoload :Timestamp + autoload :Transactions + autoload :Types + autoload :Validations + end module AttributeMethods extend ActiveSupport::Autoload - autoload :BeforeTypeCast - autoload :Dirty - autoload :PrimaryKey - autoload :Query - autoload :Read - autoload :TimeZoneConversion - autoload :Write + eager_autoload do + autoload :BeforeTypeCast + autoload :Dirty + autoload :PrimaryKey + autoload :Query + autoload :Read + autoload :TimeZoneConversion + autoload :Write + end end module Attributes extend ActiveSupport::Autoload - autoload :Aliasing - autoload :Store - autoload :Typecasting + eager_autoload do + autoload :Aliasing + autoload :Store + autoload :Typecasting + end end module Type extend ActiveSupport::Autoload - autoload :Number, 'active_record/types/number' - autoload :Object, 'active_record/types/object' - autoload :Serialize, 'active_record/types/serialize' - autoload :TimeWithZone, 'active_record/types/time_with_zone' - autoload :Unknown, 'active_record/types/unknown' + eager_autoload do + autoload :Number, 'active_record/types/number' + autoload :Object, 'active_record/types/object' + autoload :Serialize, 'active_record/types/serialize' + autoload :TimeWithZone, 'active_record/types/time_with_zone' + autoload :Unknown, 'active_record/types/unknown' + end end module Locking extend ActiveSupport::Autoload - autoload :Optimistic - autoload :Pessimistic + eager_autoload do + autoload :Optimistic + autoload :Pessimistic + end end module ConnectionAdapters extend ActiveSupport::Autoload - autoload :AbstractAdapter + eager_autoload do + autoload :AbstractAdapter + end end end diff --git a/activeresource/lib/active_resource.rb b/activeresource/lib/active_resource.rb index 3e4a1dd4a1..e0a6ecbcce 100644 --- a/activeresource/lib/active_resource.rb +++ b/activeresource/lib/active_resource.rb @@ -33,12 +33,14 @@ require 'active_model' module ActiveResource extend ActiveSupport::Autoload - autoload :Base - autoload :Connection - autoload :CustomMethods - autoload :Formats - autoload :HttpMock - autoload :Observing - autoload :Schema - autoload :Validations + eager_autoload do + autoload :Base + autoload :Connection + autoload :CustomMethods + autoload :Formats + autoload :HttpMock + autoload :Observing + autoload :Schema + autoload :Validations + end end diff --git a/activesupport/lib/active_support.rb b/activesupport/lib/active_support.rb index 9e21b3faf3..f2baa5a56a 100644 --- a/activesupport/lib/active_support.rb +++ b/activesupport/lib/active_support.rb @@ -39,31 +39,34 @@ require "active_support/dependencies/autoload" module ActiveSupport extend ActiveSupport::Autoload - autoload :BacktraceCleaner - autoload :Base64 - autoload :BasicObject - autoload :Benchmarkable - autoload :BufferedLogger - autoload :Cache - autoload :Callbacks - autoload :Concern - autoload :Configurable - autoload :DeprecatedCallbacks - autoload :Deprecation - autoload :Gzip - autoload :Inflector - autoload :Memoizable - autoload :MessageEncryptor - autoload :MessageVerifier - autoload :Multibyte - autoload :OptionMerger - autoload :OrderedHash - autoload :OrderedOptions - autoload :Notifications - autoload :Rescuable - autoload :SecureRandom - autoload :StringInquirer - autoload :XmlMini + # TODO: Narrow this list down + eager_autoload do + autoload :BacktraceCleaner + autoload :Base64 + autoload :BasicObject + autoload :Benchmarkable + autoload :BufferedLogger + autoload :Cache + autoload :Callbacks + autoload :Concern + autoload :Configurable + autoload :DeprecatedCallbacks + autoload :Deprecation + autoload :Gzip + autoload :Inflector + autoload :Memoizable + autoload :MessageEncryptor + autoload :MessageVerifier + autoload :Multibyte + autoload :OptionMerger + autoload :OrderedHash + autoload :OrderedOptions + autoload :Notifications + autoload :Rescuable + autoload :SecureRandom + autoload :StringInquirer + autoload :XmlMini + end end require 'active_support/vendor' diff --git a/activesupport/lib/active_support/dependencies/autoload.rb b/activesupport/lib/active_support/dependencies/autoload.rb index 96ab04c61a..44edb89ad5 100644 --- a/activesupport/lib/active_support/dependencies/autoload.rb +++ b/activesupport/lib/active_support/dependencies/autoload.rb @@ -5,13 +5,13 @@ module ActiveSupport @@autoloads = {} @@under_path = nil @@at_path = nil - @@autoload_defer = false + @@eager_autoload = 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) - unless @@autoload_defer + if @@eager_autoload @@autoloads[const_name] = location end super const_name, location @@ -31,11 +31,11 @@ module ActiveSupport @@at_path = old_path end - def deferrable - old_defer, @@autoload_defer = @@autoload_defer, true + def eager_autoload + old_eager, @@eager_autoload = @@eager_autoload, true yield ensure - @@autoload_defer = old_defer + @@eager_autoload = old_eager end def self.eager_autoload! |