1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

require_dependency should require using the normal mechanism if possible to avoid double-requires

This commit is contained in:
wycats 2010-08-04 02:16:48 -07:00
parent 6d6ed55324
commit 8bf79739b4

View file

@ -276,14 +276,22 @@ module ActiveSupport #:nodoc:
end
def depend_on(file_name, swallow_load_errors = false, message = "No such file to load -- %s.rb")
path = search_for_file(file_name)
require_or_load(path || file_name)
rescue LoadError => load_error
unless swallow_load_errors
if file_name = load_error.message[/ -- (.*?)(\.rb)?$/, 1]
raise LoadError.new(message % file_name).copy_blame!(load_error)
#path = search_for_file(file_name)
require_or_load(file_name)
rescue LoadError
begin
if path = search_for_file(file_name)
require_or_load(path)
else
raise
end
rescue LoadError => load_error
unless swallow_load_errors
if file_name = load_error.message[/ -- (.*?)(\.rb)?$/, 1]
raise LoadError.new(message % file_name).copy_blame!(load_error)
end
raise
end
raise
end
end