我正在寻找active_support.rb尝试了解它使用的加载过程.它采用三种不同负荷方法:load_all!,autoload和require.为什么在同一个文件中使用三种不同的加载方式?
module ActiveSupport
def self.load_all!
[Dependencies, Deprecation, Gzip, MessageVerifier, Multibyte, SecureRandom, TimeWithZone]
end
autoload :BacktraceCleaner, 'active_support/backtrace_cleaner'
autoload :Base64, 'active_support/base64'
autoload :BasicObject, 'active_support/basic_object'
autoload :BufferedLogger, 'active_support/buffered_logger'
autoload :Cache, 'active_support/cache'
autoload :Callbacks, 'active_support/callbacks'
autoload :Deprecation, 'active_support/deprecation'
autoload :Duration, 'active_support/duration'
autoload :Gzip, 'active_support/gzip'
autoload :Inflector, 'active_support/inflector'
autoload :Memoizable, 'active_support/memoizable'
autoload :MessageEncryptor, 'active_support/message_encryptor'
autoload :MessageVerifier, 'active_support/message_verifier'
autoload :Multibyte, 'active_support/multibyte'
autoload :OptionMerger, 'active_support/option_merger'
autoload :OrderedHash, 'active_support/ordered_hash'
autoload :OrderedOptions, 'active_support/ordered_options'
autoload :Rescuable, 'active_support/rescuable'
autoload :SecureRandom, 'active_support/secure_random'
autoload :StringInquirer, …Run Code Online (Sandbox Code Playgroud) 如何显示在Ruby应用程序中发生的'require'的层次结构?
某些文件需要需要其他文件的文件.
但是,通过在调试模式下运行应用程序,您只会触发所需文件的子集 - 只有您的应用程序在任何给定时间点使用的任何功能子集所使用的文件.
如何在应用程序中显示树的所有需求的综合层次结构?
以下是整个内容activeresource.rb:
require 'active_resource'
Run Code Online (Sandbox Code Playgroud)
有人能解释一下这个逻辑吗?
为什么不简单地activeresource.rb包含什么active_resource.rb包含并忘记附加require声明?
我想知道我应该使用什么文件来确保我的初始化代码只会在应用程序启动时执行一次.environment.rb是正确使用的文件还是会在每个http请求上调用?