mirror of
https://github.com/github/rails.git
synced 2026-01-29 16:28:09 -05:00
Deprecation: removed Reloadable.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7473 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -221,10 +221,6 @@ module ActionMailer #:nodoc:
|
||||
include AdvAttrAccessor, PartContainer
|
||||
include ActionController::UrlWriter if Object.const_defined?(:ActionController)
|
||||
|
||||
# Action Mailer subclasses should be reloaded by the dispatcher in Rails
|
||||
# when Dependencies.mechanism = :load.
|
||||
include Reloadable::Deprecated
|
||||
|
||||
private_class_method :new #:nodoc:
|
||||
|
||||
class_inheritable_accessor :template_root
|
||||
|
||||
@@ -243,7 +243,6 @@ module ActionController #:nodoc:
|
||||
class Base
|
||||
DEFAULT_RENDER_STATUS_CODE = "200 OK"
|
||||
|
||||
include Reloadable::Deprecated
|
||||
include StatusCodes
|
||||
|
||||
# Determines whether the view has access to controller internals @request, @response, @session, and @template.
|
||||
@@ -1231,4 +1230,4 @@ module ActionController #:nodoc:
|
||||
close_session
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -280,15 +280,13 @@ module ActiveRecord #:nodoc:
|
||||
# Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed
|
||||
# on to any new database connections made and which can be retrieved on both a class and instance level by calling +logger+.
|
||||
cattr_accessor :logger, :instance_writer => false
|
||||
|
||||
include Reloadable::Deprecated
|
||||
|
||||
|
||||
def self.inherited(child) #:nodoc:
|
||||
@@subclasses[self] ||= []
|
||||
@@subclasses[self] << child
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
def self.reset_subclasses #:nodoc:
|
||||
nonreloadables = []
|
||||
subclasses.each do |klass|
|
||||
|
||||
@@ -127,10 +127,6 @@ module ActiveRecord
|
||||
class Observer
|
||||
include Singleton
|
||||
|
||||
# Observer subclasses should be reloaded by the dispatcher in Rails
|
||||
# when Dependencies.mechanism = :load.
|
||||
include Reloadable::Deprecated
|
||||
|
||||
class << self
|
||||
# Attaches the observer to the supplied model classes.
|
||||
def observe(*models)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Deprecation: removed Reloadable. [Jeremy Kemper]
|
||||
|
||||
* Make the utf-handler return the correct value for non-matching regular expressions. Closes #9049 [manfred]
|
||||
|
||||
* Add ljust, rjust and center to utf8-handler. Closes #9165 [manfred]
|
||||
|
||||
@@ -31,7 +31,6 @@ require 'active_support/inflector'
|
||||
require 'active_support/core_ext'
|
||||
require 'active_support/clean_logger'
|
||||
require 'active_support/dependencies'
|
||||
require 'active_support/reloadable'
|
||||
require 'active_support/deprecation'
|
||||
|
||||
require 'active_support/ordered_options'
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
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 #:nodoc:
|
||||
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?) do
|
||||
ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reloadable_classes
|
||||
ActiveSupport::Deprecation.silence do
|
||||
included_in_classes.select { |klass| klass.reloadable? }
|
||||
end
|
||||
end
|
||||
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 #:nodoc:
|
||||
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
|
||||
ActiveSupport::Deprecation.warn "Reloadable has been deprecated and reloadable? has no effect", caller
|
||||
base != self
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Deprecated #:nodoc:
|
||||
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
|
||||
@@ -1,123 +0,0 @@
|
||||
require File.dirname(__FILE__) + '/abstract_unit'
|
||||
|
||||
ActiveSupport::Deprecation.silence do
|
||||
module ReloadableTestSandbox
|
||||
class AReloadableClass
|
||||
include Reloadable
|
||||
end
|
||||
class AReloadableClassWithSubclasses
|
||||
include Reloadable
|
||||
end
|
||||
class AReloadableSubclass < AReloadableClassWithSubclasses
|
||||
end
|
||||
class ANonReloadableSubclass < AReloadableClassWithSubclasses
|
||||
def self.reloadable?
|
||||
false
|
||||
end
|
||||
end
|
||||
class AClassWhichDefinesItsOwnReloadable
|
||||
def self.reloadable?
|
||||
10
|
||||
end
|
||||
include Reloadable
|
||||
end
|
||||
|
||||
class SubclassesReloadable
|
||||
include Reloadable::Subclasses
|
||||
end
|
||||
class ASubclassOfSubclassesReloadable < SubclassesReloadable
|
||||
end
|
||||
|
||||
class AnOnlySubclassReloadableClassSubclassingAReloadableClass
|
||||
include Reloadable::Subclasses
|
||||
end
|
||||
|
||||
class ASubclassofAOnlySubclassReloadableClassWhichWasSubclassingAReloadableClass < AnOnlySubclassReloadableClassSubclassingAReloadableClass
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ReloadableTest < Test::Unit::TestCase
|
||||
def test_classes_receive_reloadable
|
||||
assert ReloadableTestSandbox::AReloadableClass.respond_to?(:reloadable?)
|
||||
end
|
||||
def test_classes_inherit_reloadable
|
||||
assert ReloadableTestSandbox::AReloadableSubclass.respond_to?(:reloadable?)
|
||||
end
|
||||
def test_reloadable_is_not_overwritten_if_present
|
||||
assert_equal 10, ReloadableTestSandbox::AClassWhichDefinesItsOwnReloadable.reloadable?
|
||||
end
|
||||
|
||||
def test_only_subclass_reloadable
|
||||
assert_deprecated_reloadable do
|
||||
assert !ReloadableTestSandbox::SubclassesReloadable.reloadable?
|
||||
assert ReloadableTestSandbox::ASubclassOfSubclassesReloadable.reloadable?
|
||||
end
|
||||
end
|
||||
|
||||
def test_inside_hierarchy_only_subclass_reloadable
|
||||
assert_deprecated_reloadable do
|
||||
assert !ReloadableTestSandbox::AnOnlySubclassReloadableClassSubclassingAReloadableClass.reloadable?
|
||||
assert ReloadableTestSandbox::ASubclassofAOnlySubclassReloadableClassWhichWasSubclassingAReloadableClass.reloadable?
|
||||
end
|
||||
end
|
||||
|
||||
def test_removable_classes
|
||||
reloadables = %w(
|
||||
AReloadableClass
|
||||
AReloadableClassWithSubclasses
|
||||
AReloadableSubclass
|
||||
AClassWhichDefinesItsOwnReloadable
|
||||
ASubclassOfSubclassesReloadable
|
||||
)
|
||||
non_reloadables = %w(
|
||||
ANonReloadableSubclass
|
||||
SubclassesReloadable
|
||||
)
|
||||
|
||||
results = []
|
||||
assert_deprecated_reloadable { results = Reloadable.reloadable_classes }
|
||||
reloadables.each do |name|
|
||||
assert results.include?(ReloadableTestSandbox.const_get(name)), "Expected #{name} to be reloadable"
|
||||
end
|
||||
non_reloadables.each do |name|
|
||||
assert ! results.include?(ReloadableTestSandbox.const_get(name)), "Expected #{name} NOT to be reloadable"
|
||||
end
|
||||
end
|
||||
|
||||
def test_including_reloadable_should_warn
|
||||
c = Class.new
|
||||
assert_deprecated_reloadable do
|
||||
c.send :include, Reloadable
|
||||
end
|
||||
|
||||
assert_deprecated_reloadable { c.reloadable? }
|
||||
end
|
||||
|
||||
def test_include_subclasses_should_warn
|
||||
c = Class.new
|
||||
result, deps = collect_deprecations do
|
||||
c.send :include, Reloadable::Subclasses
|
||||
end
|
||||
assert_equal 1, deps.size
|
||||
assert_match %r{Reloadable::Subclasses}, deps.first
|
||||
|
||||
assert_deprecated_reloadable { c.reloadable? }
|
||||
end
|
||||
|
||||
def test_include_deprecated_should_not_warn
|
||||
c = Class.new
|
||||
result, deps = collect_deprecations do
|
||||
c.send :include, Reloadable::Deprecated
|
||||
end
|
||||
assert_equal 0, deps.size
|
||||
|
||||
assert c.respond_to?(:reloadable?)
|
||||
assert_deprecated_reloadable { c.reloadable? }
|
||||
end
|
||||
|
||||
protected
|
||||
def assert_deprecated_reloadable(&block)
|
||||
assert_deprecated(/reloadable/, &block)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user