跳至内容 跳至搜索
方法
R

实例公共方法

require_dependency(filename)

警告: 此方法已过时。自动加载器的语义与 Ruby 相匹配,您不再需要对加载顺序进行防御。只需像往常一样引用类和模块即可。

不控制其父应用程序运行模式的引擎应在需要时调用 require_dependency,以防运行时模式为 :classic

# File activesupport/lib/active_support/dependencies/require_dependency.rb, line 11
def require_dependency(filename)
  filename = filename.to_path if filename.respond_to?(:to_path)

  unless filename.is_a?(String)
    raise ArgumentError, "the file name must be either a String or implement #to_path -- you passed #{filename.inspect}"
  end

  if abspath = ActiveSupport::Dependencies.search_for_file(filename)
    require abspath
  else
    require filename
  end
end