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:
147 148 149 150 151 152 153 154 155 |
# File 'lib/active_support/dependencies.rb', line 147 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:
139 140 141 142 143 144 145 |
# File 'lib/active_support/dependencies.rb', line 139 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:
169 170 171 172 173 174 175 176 177 178 |
# File 'lib/active_support/dependencies.rb', line 169 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:
180 181 182 183 184 185 186 187 188 189 |
# File 'lib/active_support/dependencies.rb', line 180 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
165 166 167 |
# File 'lib/active_support/dependencies.rb', line 165 def require_association(file_name) Dependencies.associate_with(file_name) end |
#require_dependency(file_name) ⇒ Object
161 162 163 |
# File 'lib/active_support/dependencies.rb', line 161 def require_dependency(file_name) Dependencies.depend_on(file_name) end |
#require_or_load(file_name) ⇒ Object
157 158 159 |
# File 'lib/active_support/dependencies.rb', line 157 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.
204 205 206 |
# File 'lib/active_support/dependencies.rb', line 204 def unloadable(const_desc) Dependencies.mark_for_unload const_desc end |