小编mon*_*man的帖子

为什么要自动加载,load_all!并要求在active_support.rb中使用所有内容?

我正在寻找active_support.rb尝试了解它使用的加载过程.它采用三种不同负荷方法:load_all!,autoloadrequire.为什么在同一个文件中使用三种不同的加载方式?

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 ruby-on-rails activesupport autoload

10
推荐指数
1
解决办法
2851
查看次数

如何跟踪Ruby应用程序中作为树的'require'的完整顺序和顺序?

如何显示在Ruby应用程序中发生的'require'的层次结构?

某些文件需要需要其他文件的文件.

但是,通过在调试模式下运行应用程序,您只会触发所需文件的子集 - 只有您的应用程序在任何给定时间点使用的任何功能子集所使用的文件.

如何在应用程序中显示树的所有需求的综合层次结构?

ruby ruby-on-rails require autoload

7
推荐指数
1
解决办法
759
查看次数

为什么activeresource.rb只调用active_resource.rb?

以下是整个内容activeresource.rb:

require 'active_resource'
Run Code Online (Sandbox Code Playgroud)

有人能解释一下这个逻辑吗?

为什么不简单地activeresource.rb包含什么active_resource.rb包含并忘记附加require声明?

ruby ruby-on-rails activeresource

4
推荐指数
1
解决办法
158
查看次数

是否在每个http请求上调用了environment.rb?

我想知道我应该使用什么文件来确保我的初始化代码只会在应用程序启动时执行一次.environment.rb是正确使用的文件还是会在每个http请求上调用?

initialization ruby-on-rails environment-variables

1
推荐指数
1
解决办法
238
查看次数