Class: Merb::Slices::DynamicLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/merb-slices/module.rb

Class Method Summary collapse

Class Method Details

.start(interval = nil) ⇒ Object



318
319
320
321
322
323
324
325
326
# File 'lib/merb-slices/module.rb', line 318

def self.start(interval = nil)
  self.lookup ||= Set.new(Merb::Slices.slice_files_from_search_path)
  @thread = self.every(interval || Merb::Plugins.config[:merb_slices][:autoload_interval] || 1.0) do
    current_files = Set.new(Merb::Slices.slice_files_from_search_path)
    (current_files - self.lookup).each { |f| Merb::Slices.activate_by_file(f) }
    (self.lookup - current_files).each { |f| Merb::Slices.deactivate_by_file(f) }
    self.lookup = current_files
  end
end

.stopObject



328
329
330
# File 'lib/merb-slices/module.rb', line 328

def self.stop
  @thread.exit if @thread.is_a?(Thread)
end