Class: Merb::BootLoader::ReloadClasses

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

Defined Under Namespace

Classes: TimedExecutor

Class Method Summary collapse

Methods inherited from Merb::BootLoader

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

Class Method Details

.reload(paths) ⇒ Object

Reloads all files.



881
882
883
884
885
886
887
888
# File 'lib/merb-core/bootloader.rb', line 881

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

.runObject

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



857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
# File 'lib/merb-core/bootloader.rb', line 857

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
  
end