module Sinatra::Reloader

def self.perform(klass)

needed elements.
Reloads the modified files, adding, updating and removing the
def self.perform(klass)
  reloaded_paths = []
  Watcher::List.for(klass).updated.each do |watcher|
    klass.set(:inline_templates, watcher.path) if watcher.inline_templates?
    watcher.elements.each { |element| klass.deactivate(element) }
    # Deletes all old elements.
    watcher.elements.delete_if { true }
    $LOADED_FEATURES.delete(watcher.path)
    require watcher.path
    watcher.update
    reloaded_paths << watcher.path
  end
  return if reloaded_paths.empty?
  @@after_reload.each do |block|
    block.arity.zero? ? block.call : block.call(reloaded_paths)
  end
  # Prevents after_reload from increasing each time it's reloaded.
  @@after_reload.delete_if do |blk|
    path, = blk.source_location
    path && reloaded_paths.include?(path)
  end
end

def self.registered(klass)

defines a before filter to +perform+ the reload of the modified files.
+klass+ with the modules +BaseMethods+ and +ExtensionMethods+ and
When the extension is registered it extends the Sinatra application
def self.registered(klass)
  @reloader_loaded_in ||= {}
  return if @reloader_loaded_in[klass]
  @reloader_loaded_in[klass] = true
  klass.extend BaseMethods
  klass.extend ExtensionMethods
  klass.set(:reloader) { klass.development? }
  klass.set(:reload_templates) { klass.reloader? }
  klass.before do
    if klass.reloader?
      MUTEX_FOR_PERFORM.synchronize { Reloader.perform(klass) }
    end
  end
  klass.set(:inline_templates, klass.app_file) if klass == Sinatra::Application
end

def after_reload(&block)

def after_reload(&block)
  @@after_reload << block
end