module ActiveSupport::Dependencies::Loadable
def self.exclude_from(base)
Object includes this module
def self.exclude_from(base) base.class_eval { define_method(:load, Kernel.instance_method(:load)) } end
def load(file, wrap = false)
def load(file, wrap = false) result = false load_dependency(file) { result = super } result end
def load_dependency(file)
def load_dependency(file) if Dependencies.load? && ActiveSupport::Dependencies.constant_watch_stack.watching? Dependencies.new_constants_in(Object) { yield } else yield end rescue Exception => exception # errors from loading file exception.blame_file! file raise end
def require(file)
def require(file) result = false load_dependency(file) { result = super } result end
def require_association(file_name)
def require_association(file_name) Dependencies.associate_with(file_name) end
def require_dependency(file_name, message = "No such file to load -- %s")
def require_dependency(file_name, message = "No such file to load -- %s") unless file_name.is_a?(String) raise ArgumentError, "the file name must be a String -- you passed #{file_name.inspect}" end Dependencies.depend_on(file_name, false, message) end
def require_or_load(file_name)
def require_or_load(file_name) Dependencies.require_or_load(file_name) end
def unloadable(const_desc)
Returns true if the constant was not previously marked for unloading, false
or a qualified constant name as a string or symbol.
The provided constant descriptor may be a (non-anonymous) module or class,
the first clear.
each constant will be removed for every subsequent clear, as opposed to for
or init scripts may list each unloadable constant that may need unloading;
Note that marking a constant for unloading need only be done once. Setup
time dependencies are cleared.
Mark the given constant as unloadable. Unloadable constants are removed each
def unloadable(const_desc) Dependencies.mark_for_unload const_desc end