class method
self.to_prepare
Ruby on Rails 3.0.20
Since v3.0.20 Last seen in v3.0.20Signature
self.to_prepare(*args, &block)
Add a preparation callback. Preparation callbacks are run before every request in development mode, and before the first request in production mode.
If a symbol with a block is given, the symbol is used as an identifier. That allows to_prepare to be called again with the same identifier to replace the existing callback. Passing an identifier is a suggested practice if the code adding a preparation block may be reloaded.
Parameters
-
argsrest -
blockblock
Source
# File actionpack/lib/action_dispatch/middleware/callbacks.rb, line 21
def self.to_prepare(*args, &block)
if args.first.is_a?(Symbol) && block_given?
define_method :"__#{args.first}", &block
set_callback(:prepare, :"__#{args.first}")
else
set_callback(:prepare, *args, &block)
end
end
Defined in actionpack/lib/action_dispatch/middleware/callbacks.rb line 21
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Callbacks