aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/dependencies.rb
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-08-04 02:16:48 -0700
committerwycats <wycats@gmail.com>2010-08-04 03:25:57 -0700
commit8bf79739b4219eb1d6464e6eb4853e92e81d7621 (patch)
treec0fd3de52d2a6ed688a87db488babd87c7744447 /activesupport/lib/active_support/dependencies.rb
parent6d6ed5532416aa75889cd34a669696ba640abeb5 (diff)
downloadrails-8bf79739b4219eb1d6464e6eb4853e92e81d7621.tar.gz
rails-8bf79739b4219eb1d6464e6eb4853e92e81d7621.tar.bz2
rails-8bf79739b4219eb1d6464e6eb4853e92e81d7621.zip
require_dependency should require using the normal mechanism if possible to avoid double-requires
Diffstat (limited to 'activesupport/lib/active_support/dependencies.rb')
-rw-r--r--activesupport/lib/active_support/dependencies.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 2b80bd214f..1b93eac7ee 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -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