Module: ActiveSupport::Dependencies::Loadable
- Defined in:
- lib/active_support/dependencies.rb
Overview
Object includes this module
Class Method Summary collapse
-
.excluded(base) ⇒ Object
:nodoc:.
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#load_with_new_constant_marking(file, *extras) ⇒ Object
:nodoc:.
-
#require(file, *extras) ⇒ Object
:nodoc:.
- #require_association(file_name) ⇒ Object
- #require_dependency(file_name) ⇒ Object
- #require_or_load(file_name) ⇒ Object
-
#unloadable(const_desc) ⇒ Object
Mark the given constant as unloadable.
Class Method Details
.excluded(base) ⇒ Object
:nodoc:
121 122 123 124 125 126 127 128 129 |
# File 'lib/active_support/dependencies.rb', line 121 def self.excluded(base) #:nodoc: base.class_eval do if defined? load_without_new_constant_marking undef_method :load alias_method :load, :load_without_new_constant_marking undef_method :load_without_new_constant_marking end end end |
.included(base) ⇒ Object
:nodoc:
113 114 115 116 117 118 119 |
# File 'lib/active_support/dependencies.rb', line 113 def self.included(base) #:nodoc: base.class_eval do unless defined? load_without_new_constant_marking alias_method_chain :load, :new_constant_marking end end end |
Instance Method Details
#load_with_new_constant_marking(file, *extras) ⇒ Object
:nodoc:
143 144 145 146 147 148 149 150 151 152 |
# File 'lib/active_support/dependencies.rb', line 143 def load_with_new_constant_marking(file, *extras) #:nodoc: if Dependencies.load? Dependencies.new_constants_in(Object) { load_without_new_constant_marking(file, *extras) } else load_without_new_constant_marking(file, *extras) end rescue Exception => exception # errors from loading file exception.blame_file! file raise end |
#require(file, *extras) ⇒ Object
:nodoc:
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/active_support/dependencies.rb', line 154 def require(file, *extras) #:nodoc: if Dependencies.load? Dependencies.new_constants_in(Object) { super } else super end rescue Exception => exception # errors from required file exception.blame_file! file raise end |
#require_association(file_name) ⇒ Object
139 140 141 |
# File 'lib/active_support/dependencies.rb', line 139 def require_association(file_name) Dependencies.associate_with(file_name) end |
#require_dependency(file_name) ⇒ Object
135 136 137 |
# File 'lib/active_support/dependencies.rb', line 135 def require_dependency(file_name) Dependencies.depend_on(file_name) end |
#require_or_load(file_name) ⇒ Object
131 132 133 |
# File 'lib/active_support/dependencies.rb', line 131 def require_or_load(file_name) Dependencies.require_or_load(file_name) end |
#unloadable(const_desc) ⇒ Object
Mark the given constant as unloadable. Unloadable constants are removed each time dependencies are cleared.
Note that marking a constant for unloading need only be done once. Setup or init scripts may list each unloadable constant that may need unloading; each constant will be removed for every subsequent clear, as opposed to for the first clear.
The provided constant descriptor may be a (non-anonymous) module or class, or a qualified constant name as a string or symbol.
Returns true if the constant was not previously marked for unloading, false otherwise.
178 179 180 |
# File 'lib/active_support/dependencies.rb', line 178 def unloadable(const_desc) Dependencies.mark_for_unload const_desc end |