module Sinatra::SinareyReloader::ExtensionMethods

Attributes

register_path[R]

Public Instance Methods

also_reload(*glob) click to toggle source
# File lib/sinatra/sinarey_reloader.rb, line 219
def also_reload(*glob)
  Dir[*glob].each { |path| Watcher::List.for(self).watch_file(path) }
end
deactivate(element) click to toggle source
# File lib/sinatra/sinarey_reloader.rb, line 192
def deactivate(element)
  case element.type
  when :route then
    verb      = element.representation[:verb]
    signature = element.representation[:signature]
    block_id  = signature.last
    (blocks ||= {}).delete(block_id)
    (routes[verb] ||= []).delete(signature)
  when :turbo_route then
    verb      = element.representation[:verb]
    path      = element.representation[:path]
    block_id  = element.representation[:block_id]
    (blocks ||= {}).delete(block_id)
    (turbo_routes[verb] ||= {}).delete(path)
  when :middleware then
    @middleware.delete(element.representation)
  when :before_filter then
    filters[:before].delete(element.representation)
  when :after_filter then
    filters[:after].delete(element.representation)
  when :error then
    code    = element.representation[:code]
    handler = element.representation[:handler]
    @errors.delete(code) if @errors[code] == handler
  end
end
dont_reload(*glob) click to toggle source
# File lib/sinatra/sinarey_reloader.rb, line 223
def dont_reload(*glob)
  Dir[*glob].each { |path| Watcher::List.for(self).ignore(path) }
end

Private Instance Methods

registering_extension?() click to toggle source
# File lib/sinatra/sinarey_reloader.rb, line 239
def registering_extension?
  !register_path.nil?
end
start_registering_extension() click to toggle source
# File lib/sinatra/sinarey_reloader.rb, line 231
def start_registering_extension
  @register_path = caller_files[2]
end
stop_registering_extension() click to toggle source
# File lib/sinatra/sinarey_reloader.rb, line 235
def stop_registering_extension
  @register_path = nil
end
watch_element(path, type, representation=nil) click to toggle source
# File lib/sinatra/sinarey_reloader.rb, line 243
def watch_element(path, type, representation=nil)
  list = Watcher::List.for(self)
  element = Watcher::Element.new(type, representation)
  list.watch(path, element)
  list.watch(register_path, element) if registering_extension?
end