diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-06-10 12:12:15 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-06-10 12:15:30 -0700 |
commit | 4fc0778123fc775d106f6bc8a4a2a362bf0047ed (patch) | |
tree | 71d9146d0a2ede4d71c1f99a4969ed6cca1d8b9b /activesupport/lib/active_support | |
parent | c014c3e5c14beb71fa7c67f15448386d0ffaba28 (diff) | |
download | rails-4fc0778123fc775d106f6bc8a4a2a362bf0047ed.tar.gz rails-4fc0778123fc775d106f6bc8a4a2a362bf0047ed.tar.bz2 rails-4fc0778123fc775d106f6bc8a4a2a362bf0047ed.zip |
Simplify helper use of ActiveSupport::Dependencies, and use super better for in #helpers
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 855b720ef1..7f6f012721 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -143,8 +143,8 @@ module ActiveSupport #:nodoc: Dependencies.require_or_load(file_name) end - def require_dependency(file_name) - Dependencies.depend_on(file_name) + def require_dependency(file_name, message = "No such file to load -- %s") + Dependencies.depend_on(file_name, false, message) end def require_association(file_name) @@ -230,11 +230,16 @@ module ActiveSupport #:nodoc: mechanism == :load end - def depend_on(file_name, swallow_load_errors = false) + 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 - raise unless swallow_load_errors + rescue LoadError => load_error + unless swallow_load_errors + if file_name = load_error.message[/ -- (.*?)(\.rb)?$/, 1] + raise MissingSourceFile.new(message % file_name, load_error.path).copy_blame!(load_error) + end + raise + end end def associate_with(file_name) |