diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-28 20:39:26 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-28 20:39:26 +0000 |
commit | e47c8381e127fe36aa20f8343e46d065045a6445 (patch) | |
tree | 709582e38260c3066d0fbd99c56fe9a9f90fffc0 /activesupport | |
parent | ca7341d2a5375218a480ca4add04991c87dc7c75 (diff) | |
download | rails-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')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 26 | ||||
-rw-r--r-- | activesupport/test/dependencies/mutual_one.rb | 2 | ||||
-rw-r--r-- | activesupport/test/dependencies/mutual_two.rb | 2 |
3 files changed, 15 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 diff --git a/activesupport/test/dependencies/mutual_one.rb b/activesupport/test/dependencies/mutual_one.rb index eb5e056efb..576eb31711 100644 --- a/activesupport/test/dependencies/mutual_one.rb +++ b/activesupport/test/dependencies/mutual_one.rb @@ -1,2 +1,4 @@ $mutual_dependencies_count += 1 require_dependency 'mutual_two' +require_dependency 'mutual_two.rb' +require_dependency 'mutual_two' diff --git a/activesupport/test/dependencies/mutual_two.rb b/activesupport/test/dependencies/mutual_two.rb index 99ba337e55..fdbc2dcd84 100644 --- a/activesupport/test/dependencies/mutual_two.rb +++ b/activesupport/test/dependencies/mutual_two.rb @@ -1,2 +1,4 @@ $mutual_dependencies_count += 1 +require_dependency 'mutual_one.rb' require_dependency 'mutual_one' +require_dependency 'mutual_one.rb' |