Class: Merb::BootLoader::ReloadClasses
- Inherits:
-
Merb::BootLoader
- Object
- Merb::BootLoader
- Merb::BootLoader::ReloadClasses
- Defined in:
- lib/merb-core/bootloader.rb
Defined Under Namespace
Classes: TimedExecutor
Class Method Summary collapse
-
.reload(paths) ⇒ Object
Reloads all files which have been modified since they were last loaded.
-
.run ⇒ Object
Set up the class reloader if class reloading is enabled.
Methods inherited from Merb::BootLoader
after, after_app_loads, before, before_app_loads, before_master_shutdown, before_worker_shutdown, default_framework, finished?, inherited, move_klass
Class Method Details
.reload(paths) ⇒ Object
Reloads all files which have been modified since they were last loaded.
Returns
nil
:api: private
1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 |
# File 'lib/merb-core/bootloader.rb', line 1347 def self.reload(paths) paths.each do |file| next if LoadClasses::MTIMES[file] && LoadClasses::MTIMES[file] == File.mtime(file) LoadClasses.reload(file) end nil end |
.run ⇒ Object
Set up the class reloader if class reloading is enabled. This checks periodically for modifications to files loaded by the LoadClasses BootLoader and reloads them when they are modified.
Returns
nil
:api: plugin
1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 |
# File 'lib/merb-core/bootloader.rb', line 1317 def self.run return unless Merb::Config[:reload_classes] paths = [] Merb.load_paths.each do |path_name, file_info| path, glob = file_info next unless glob paths << Dir[path / glob] end if Merb.dir_for(:application) && File.file?(Merb.dir_for(:application)) paths << Merb.dir_for(:application) end paths.flatten! TimedExecutor.every(Merb::Config[:reload_time] || 0.5) do GC.start reload(paths) end nil end |