Class: Merb::BootLoader::ReloadClasses

Inherits:
Merb::BootLoader show all
Defined in:
lib/merb-core/bootloader.rb

Class Method Summary collapse

Methods inherited from Merb::BootLoader

after, after_app_loads, before, before_app_loads, default_framework, inherited, move_klass

Class Method Details

.reloadObject

Reloads all files.



576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
# File 'lib/merb-core/bootloader.rb', line 576

def self.reload
  paths = []
  Merb.load_paths.each do |path_name, file_info|
    path, glob = file_info
    next unless glob
    paths << Dir[path / glob]
  end
  
  paths << Merb.dir_for(:application) if Merb.dir_for(:application) && File.file?(Merb.dir_for(:application))

  paths.flatten.each do |file|
    next if Merb::BootLoader::LoadClasses::MTIMES[file] && Merb::BootLoader::LoadClasses::MTIMES[file] == File.mtime(file)
    Merb::BootLoader::LoadClasses.reload(file)
  end    
end

.runObject

Setup the class reloader if it’s been specified in config.



562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/merb-core/bootloader.rb', line 562

def self.run
  return unless Merb::Config[:reload_classes]

  Thread.abort_on_exception = true
  Thread.new do
    loop do
      sleep( Merb::Config[:reload_time] || 0.5 )
      reload
    end
    Thread.exit
  end
end