Module: Dependencies
Overview
:nodoc:
Defined Under Namespace
Classes: LoadingModule
Instance Method Summary collapse
- #associate_with(file_name) ⇒ Object
- #clear ⇒ Object
- #depend_on(file_name, swallow_load_errors = false) ⇒ Object
- #load? ⇒ Boolean
- #require_or_load(file_name) ⇒ Object
Instance Method Details
#associate_with(file_name) ⇒ Object
35 36 37 |
# File 'lib/active_support/dependencies.rb', line 35 def associate_with(file_name) depend_on(file_name, true) end |
#clear ⇒ Object
39 40 41 |
# File 'lib/active_support/dependencies.rb', line 39 def clear loaded.clear end |
#depend_on(file_name, swallow_load_errors = false) ⇒ Object
29 30 31 32 33 |
# File 'lib/active_support/dependencies.rb', line 29 def depend_on(file_name, swallow_load_errors = false) require_or_load(file_name) rescue LoadError raise unless swallow_load_errors end |
#load? ⇒ Boolean
25 26 27 |
# File 'lib/active_support/dependencies.rb', line 25 def load? mechanism == :load end |
#require_or_load(file_name) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/active_support/dependencies.rb', line 43 def require_or_load(file_name) 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 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 "#{file_name}.rb" else enable_warnings { load "#{file_name}.rb" } end rescue loaded.delete file_name raise end else require file_name end # Record history *after* loading so first load gets warnings. history << file_name end |