Prepare callbacks are run before each request, and cleanup callbacks after
each request. In this respect they are analogs of
ActionDispatch::Callback's before and after callbacks. However, cleanup
callbacks are not called until the request is fully complete – that is,
after close has been called on the response body. This is important for
streaming responses such as the following:

Cleanup callbacks will not be called until after the response_body lambda
is evaluated, ensuring that it can refer to application models and other
classes before they are unloaded.

By default, ActionDispatch::Reloader is
included in the middleware stack only in the development environment;
specifically, when config.cache_classes is false. Callbacks may be registered even when it is not
included in the middleware stack, but are executed only when
ActionDispatch::Reloader.prepare! or
ActionDispatch::Reloader.cleanup! are called manually.

# File actionpack/lib/action_dispatch/middleware/reloader.rb, line 46defself.to_cleanup(*args, &block)
unlessblock_given?warn"to_cleanup without a block is deprecated. Please use a block"endset_callback(:cleanup, *args, &block)
end

# File actionpack/lib/action_dispatch/middleware/reloader.rb, line 37defself.to_prepare(*args, &block)
unlessblock_given?warn"to_prepare without a block is deprecated. Please use a block"endset_callback(:prepare, *args, &block)
end