Active Support Reloader
This class defines several callbacks:
to_prepare -- Run once at application startup, and also from
+to_run+.
to_run -- Run before a work run that is reloading. If
+reload_classes_only_on_change+ is true (the default), the class
unload will have already occurred.
to_complete -- Run after a work run that has reloaded. If
+reload_classes_only_on_change+ is false, the class unload will
have occurred after the work run, but before this callback.
before_class_unload -- Run immediately before the classes are
unloaded.
after_class_unload -- Run immediately after the classes are
unloaded.
- A
- B
- N
- R
- T
- W
Class Public methods
after_class_unload(*args, &block) Link
Registers a callback that will run immediately after the classes are unloaded.
Source: show
# File activesupport/lib/active_support/reloader.rb, line 44 def self.after_class_unload(*args, &block) set_callback(:class_unload, :after, *args, &block) end
before_class_unload(*args, &block) Link
Registers a callback that will run immediately before the classes are unloaded.
Source: show
# File activesupport/lib/active_support/reloader.rb, line 39 def self.before_class_unload(*args, &block) set_callback(:class_unload, *args, &block) end
new() Link
Source: show
# File activesupport/lib/active_support/reloader.rb, line 99 def initialize super @locked = false end
reload!() Link
Initiate a manual reload
Source: show
# File activesupport/lib/active_support/reloader.rb, line 51 def self.reload! executor.wrap do new.tap do |instance| instance.run! ensure instance.complete! end end prepare! end
to_prepare(*args, &block) Link
Registers a callback that will run once at application startup and every time the code is reloaded.
Source: show
# File activesupport/lib/active_support/reloader.rb, line 34 def self.to_prepare(*args, &block) set_callback(:prepare, *args, &block) end
wrap(**kwargs) Link
Run the supplied block as a work unit, reloading code as needed
Source: show
# File activesupport/lib/active_support/reloader.rb, line 71 def self.wrap(**kwargs) return yield if active? executor.wrap(**kwargs) do instance = run! begin yield ensure instance.complete! end end end
Instance Public methods
release_unload_lock!() Link
Release the unload lock if it has been previously obtained
Source: show
# File activesupport/lib/active_support/reloader.rb, line 114 def release_unload_lock! if @locked @locked = false ActiveSupport::Dependencies.interlock.done_unloading end end
require_unload_lock!() Link
Acquire the ActiveSupport::Dependencies::Interlock unload lock, ensuring it will be released automatically
Source: show
# File activesupport/lib/active_support/reloader.rb, line 106 def require_unload_lock! unless @locked ActiveSupport::Dependencies.interlock.start_unloading @locked = true end end