Method: Im::Loader::Config#on_unload
- Defined in:
- lib/im/loader/config.rb
#on_unload(cpath = :ANY, &block) ⇒ Object
Configure a block to be invoked right before a certain constant is removed. Supports multiple callbacks, and if there are many, they are executed in the order in which they were defined.
loader.on_unload("Country") do |klass, _abspath|
klass.clear_cache
end
Can also be configured for any removed constant:
loader.on_unload do |cpath, value, abspath|
# ...
end
259 260 261 262 263 264 265 |
# File 'lib/im/loader/config.rb', line 259 def on_unload(cpath = :ANY, &block) raise TypeError, "on_unload only accepts strings" unless cpath.is_a?(String) || cpath == :ANY mutex.synchronize do (on_unload_callbacks[cpath] ||= []) << block end end |