aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/dependencies.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-28 20:39:26 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-28 20:39:26 +0000
commite47c8381e127fe36aa20f8343e46d065045a6445 (patch)
tree709582e38260c3066d0fbd99c56fe9a9f90fffc0 /activesupport/lib/active_support/dependencies.rb
parentca7341d2a5375218a480ca4add04991c87dc7c75 (diff)
downloadrails-e47c8381e127fe36aa20f8343e46d065045a6445.tar.gz
rails-e47c8381e127fe36aa20f8343e46d065045a6445.tar.bz2
rails-e47c8381e127fe36aa20f8343e46d065045a6445.zip
Handle mutual dependencies with .rb suffix.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3193 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/dependencies.rb')
-rw-r--r--activesupport/lib/active_support/dependencies.rb26
1 files changed, 11 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 64732db136..8d1288cd96 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -27,13 +27,9 @@ module Dependencies #:nodoc:
end
def depend_on(file_name, swallow_load_errors = false)
- unless loaded.include?(file_name)
- begin
- require_or_load(file_name)
- rescue LoadError
- raise unless swallow_load_errors
- end
- end
+ require_or_load(file_name)
+ rescue LoadError
+ raise unless swallow_load_errors
end
def associate_with(file_name)
@@ -45,21 +41,21 @@ module Dependencies #:nodoc:
end
def require_or_load(file_name)
- if load?
- # Append .rb if we have a bare file name.
- load_file_name = (file_name =~ /\.rb$/ ? file_name : "#{file_name}.rb")
+ file_name = $1 if file_name =~ /^(.*)\.rb$/
+ return if loaded.include?(file_name)
- # Record that we've seen this file *before* loading it to avoid an
- # infinite loop with mutual dependencies.
- loaded << file_name
+ # Record that we've seen this file *before* loading it to avoid an
+ # infinite loop with mutual dependencies.
+ loaded << file_name
+ if load?
begin
# Enable warnings iff this file has not been loaded before and
# warnings_on_first_load is set.
if !warnings_on_first_load or history.include?(file_name)
- load load_file_name
+ load "#{file_name}.rb"
else
- enable_warnings { load load_file_name }
+ enable_warnings { load "#{file_name}.rb" }
end
rescue
loaded.delete file_name