Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deletes the classic implementation of require_dependency
- Loading branch information
Showing
4 changed files
with
40 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
activesupport/lib/active_support/dependencies/require_dependency.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActiveSupport::Dependencies::RequireDependency | ||
# <b>Warning:</b> This method is obsolete. The semantics of the autoloader | ||
# match Ruby's and you do not need to be defensive with load order anymore. | ||
# Just refer to classes and modules normally. | ||
# | ||
# Engines that do not control the mode in which their parent application runs | ||
# should call +require_dependency+ where needed in case the runtime mode is | ||
# +:classic+. | ||
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 | ||
|
||
# We could define require_dependency in Object directly, but a module makes | ||
# the extension apparent if you list ancestors. | ||
Object.prepend(self) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters