Module: Sinatra::SinareyReloader::ExtensionMethods

Defined in:
lib/sinatra/sinarey_reloader.rb

Instance Method Summary collapse

Instance Method Details

#also_reload(*glob) ⇒ Object



219
220
221
# 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) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# 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) ⇒ Object



223
224
225
# File 'lib/sinatra/sinarey_reloader.rb', line 223

def dont_reload(*glob)
  Dir[*glob].each { |path| Watcher::List.for(self).ignore(path) }
end