Module: Sinatra::Reloader::BaseMethods
Relationships & Source Files | |
Defined in: | sinatra-contrib/lib/sinatra/reloader.rb |
Overview
Contains the methods defined in ::Sinatra::Base
that are overridden.
Instance Method Summary
-
#add_filter(type, path = nil, **options, &block)
Does everything Sinatra::Base#add_filter does, but it also tells the
Watcher::List
for the::Sinatra
application to watch the defined filter. -
#compile!(verb, path, block, **options)
Does everything Sinatra::Base#route does, but it also tells the
Watcher::List
for the::Sinatra
application to watch the defined route. -
#error(*codes, &block)
Does everything Sinatra::Base#error does, but it also tells the
Watcher::List
for the::Sinatra
application to watch the defined error handler. -
#inherited(subclass)
Does everything Sinatra::Base#register does and then registers the reloader in the
subclass
. -
#inline_templates=(file = nil)
Does everything Sinatra::Base#inline_templates= does, but it also tells the
Watcher::List
for the::Sinatra
application to watch the inline templates infile
or the file who made the call to this method. -
#register(*extensions, &block)
Does everything Sinatra::Base#register does, but it also lets the reloader know that an extension is being registered, because the elements defined in its registered method need a special treatment.
-
#run!(*args)
Protects Sinatra::Base.run! from being called more than once.
-
#use(middleware, *args, &block)
Does everything Sinatra::Base#use does, but it also tells the
Watcher::List
for the::Sinatra
application to watch the middleware being used.
Instance Method Details
#add_filter(type, path = nil, **options, &block)
Does everything Sinatra::Base#add_filter does, but it also tells
the Watcher::List
for the ::Sinatra
application to watch the defined
filter.
# File 'sinatra-contrib/lib/sinatra/reloader.rb', line 320
def add_filter(type, path = nil, **, &block) source_location = block.respond_to?(:source_location) ? block.source_location.first : caller_files[1] result = super watch_element(source_location, :"#{type}_filter", filters[type].last) result end
#compile!(verb, path, block, **options)
Does everything Sinatra::Base#route does, but it also tells the
Watcher::List
for the ::Sinatra
application to watch the defined
route.
Note: We are using #compile! so we don't interfere with extensions changing #route.
# File 'sinatra-contrib/lib/sinatra/reloader.rb', line 288
def compile!(verb, path, block, ** ) source_location = block.respond_to?(:source_location) ? block.source_location.first : caller_files[1] signature = super watch_element( source_location, :route, { verb: verb, signature: signature } ) signature end
#error(*codes, &block)
Does everything Sinatra::Base#error does, but it also tells the
Watcher::List
for the ::Sinatra
application to watch the defined
error handler.
#inherited(subclass)
Does everything Sinatra::Base#register does and then registers the
reloader in the subclass
.
#inline_templates=(file = nil)
Does everything Sinatra::Base#inline_templates= does, but it also
tells the Watcher::List
for the ::Sinatra
application to watch the
inline templates in file
or the file who made the call to this
method.
# File 'sinatra-contrib/lib/sinatra/reloader.rb', line 302
def inline_templates=(file = nil) file = (caller_files[1] || File. ($0)) if file.nil? || file == true watch_element(file, :inline_templates) super end
#register(*extensions, &block)
Does everything Sinatra::Base#register does, but it also lets the reloader know that an extension is being registered, because the elements defined in its Sinatra::Reloader.registered method need a special treatment.
# File 'sinatra-contrib/lib/sinatra/reloader.rb', line 343
def register(*extensions, &block) start_registering_extension result = super stop_registering_extension result end
#run!(*args)
Protects Sinatra::Base.run! from being called more than once.
# File 'sinatra-contrib/lib/sinatra/reloader.rb', line 274
def run!(*args) if settings.reloader? super unless running? else super end end
#use(middleware, *args, &block)
Does everything Sinatra::Base#use does, but it also tells the
Watcher::List
for the ::Sinatra
application to watch the middleware
being used.
# File 'sinatra-contrib/lib/sinatra/reloader.rb', line 311
def use(middleware, *args, &block) path = caller_files[1] || File. ($0) watch_element(path, :middleware, [middleware, args, block]) super end