diff options
Diffstat (limited to 'activesupport/lib/active_support/reloadable.rb')
-rw-r--r-- | activesupport/lib/active_support/reloadable.rb | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/reloadable.rb b/activesupport/lib/active_support/reloadable.rb index 3fd13e3d0f..3f57723e15 100644 --- a/activesupport/lib/active_support/reloadable.rb +++ b/activesupport/lib/active_support/reloadable.rb @@ -1,13 +1,25 @@ -# Classes that include this module will automatically be reloaded -# by the Rails dispatcher when Dependencies.mechanism = :load. +require 'active_support/deprecation' + +# A deprecated mechanism to mark a class reloadable. +# +# Deprecated as of Rails 1.2. +# All autoloaded objects are now unloaded. module Reloadable class << self + def included(base) #nodoc: + unless base.ancestors.include?(Reloadable::Subclasses) # Avoid double warning + ActiveSupport::Deprecation.warn "Reloadable has been deprecated and has no effect.", caller + end + raise TypeError, "Only Classes can be Reloadable!" unless base.is_a? Class unless base.respond_to?(:reloadable?) class << base - define_method(:reloadable?) { true } + define_method(:reloadable?) do + ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller + true + end end end end @@ -15,16 +27,37 @@ module Reloadable def reloadable_classes included_in_classes.select { |klass| klass.reloadable? } end + # Commented out so dispatcher doesn't warn. Should we just disable Reloadable? + # deprecate :reloadable_classes end # Captures the common pattern where a base class should not be reloaded, # but its subclasses should be. + # + # Deprecated as of Rails 1.2. + # All autoloaded objects are now unloaded. module Subclasses def self.included(base) #nodoc: base.send :include, Reloadable + ActiveSupport::Deprecation.warn "Reloadable::Subclasses has been deprecated and has no effect.", caller (class << base; self; end).send(:define_method, :reloadable?) do - base != self + ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller + base != self end end end + + module Deprecated + + def self.included(base) + class << base + define_method(:reloadable?) do + ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller + true # This might not have the desired effect, as AR::B.reloadable? => true. + end + end + end + + end + end
\ No newline at end of file |