Delete AS::Dependencies::Loadable

This commit is contained in:
Xavier Noria 2021-08-18 22:31:07 +02:00
parent a7a217212b
commit 27262897c7
1 changed files with 0 additions and 69 deletions

View File

@ -181,75 +181,6 @@ module ActiveSupport # :nodoc:
# An internal stack used to record which constants are loaded by any block.
mattr_accessor :constant_watch_stack, default: WatchStack.new
# Object includes this module.
module Loadable # :nodoc:
def self.exclude_from(base)
base.class_eval do
define_method(:load, Kernel.instance_method(:load))
private :load
define_method(:require, Kernel.instance_method(:require))
private :require
end
end
def self.include_into(base)
base.include(self)
if base.instance_method(:load).owner == base
base.remove_method(:load)
end
if base.instance_method(:require).owner == base
base.remove_method(:require)
end
end
def require_or_load(file_name)
Dependencies.require_or_load(file_name)
end
def load_dependency(file)
if Dependencies.load? && Dependencies.constant_watch_stack.watching?
descs = Dependencies.constant_watch_stack.watching.flatten.uniq
Dependencies.new_constants_in(*descs) { yield }
else
yield
end
end
# Mark the given constant as unloadable. Unloadable constants are removed
# each time dependencies are cleared.
#
# Note that marking a constant for unloading need only be done once. Setup
# or init scripts may list each unloadable constant that may need unloading;
# each constant will be removed for every subsequent clear, as opposed to
# for the first clear.
#
# The provided constant descriptor may be a (non-anonymous) module or class,
# or a qualified constant name as a string or symbol.
#
# Returns +true+ if the constant was not previously marked for unloading,
# +false+ otherwise.
def unloadable(const_desc)
Dependencies.mark_for_unload const_desc
end
private
def load(file, wrap = false)
result = false
load_dependency(file) { result = super }
result
end
def require(file)
result = false
load_dependency(file) { result = super }
result
end
end
def load?
mechanism == :load
end