instance method
require_dependency
Ruby on Rails 5.2.8.1
Since v5.2.8.1 Last seen in v6.1.7.10Signature
require_dependency(file_name, message = "No such file to load -- %s.rb")
Interprets a file using mechanism and marks its defined constants as autoloaded. file_name can be either a string or respond to to_path.
Use this method in code that absolutely needs a certain constant to be defined at that point. A typical use case is to make constant name resolution deterministic for constants with the same relative name in different namespaces whose evaluation would depend on load order otherwise.
Parameters
-
file_namereq -
messageopt = "No such file to load -- %s.rb"
Source
# File activesupport/lib/active_support/dependencies.rb, line 240
def require_dependency(file_name, message = "No such file to load -- %s.rb")
file_name = file_name.to_path if file_name.respond_to?(:to_path)
unless file_name.is_a?(String)
raise ArgumentError, "the file name must either be a String or implement #to_path -- you passed #{file_name.inspect}"
end
Dependencies.depend_on(file_name, message)
end
Defined in activesupport/lib/active_support/dependencies.rb line 240
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Dependencies::Loadable