Class Merb::BootLoader::LoadClasses
In: lib/merb-core/bootloader.rb
Parent: Merb::BootLoader

Load all classes inside the load paths.

This is used in conjunction with Merb::BootLoader::ReloadClasses to track files that need to be reloaded, and which constants need to be removed in order to reload a file.

This also adds the model, controller, and lib directories to the load path, so they can be required in order to avoid load-order issues.

Methods

Constants

LOADED_CLASSES = {}
MTIMES = {}
FILES_LOADED = {}

Public Class methods

Wait for any children to exit, remove the "main" PID, and exit.

Returns

(Does not return.)

:api: private

Load classes from given paths - using path/glob pattern.

Parameters

*paths<Array>:Array of paths to load classes from - may contain glob pattern

Returns

nil

:api: private

Loads a file, tracking its modified time and, if necessary, the classes it declared.

Parameters

file<String>:The file to load.

Returns

nil

:api: private

Reap any workers of the spawner process and exit with an appropriate status code.

Note that exiting the spawner process with a status code of 128 when a master process exists will cause the spawner process to be recreated, and the app code reloaded.

Parameters

status<Integer>:The status code to exit with. Defaults to 0.
sig<String>:The signal to send to workers

Returns

(Does not return.)

:api: private

Reloads the classes in the specified file. If fork-based loading is used, this causes the current processes to be killed and and all classes to be reloaded. If class-based loading is not in use, the classes declared in that file are removed and the file is reloaded.

Parameters

file<String>:The file to reload.

Returns

When fork-based loading is used:

  (Does not return.)

When fork-based loading is not in use:

  nil

:api: private

Removes all classes declared in the specified file. Any hashes which use classes as keys will be protected provided they have been added to Merb.klass_hashes. These hashes have their keys substituted with placeholders before the file‘s classes are unloaded. If a block is provided, it is called before the substituted keys are reconstituted.

Parameters

file<String>:The file to remove classes for.
&block:A block to call with the file that has been removed before klass_hashes are updated

to use the current values of the constants they used as keys.

Returns

nil

:api: private

Removes the specified class.

Additionally, removes the specified class from the subclass list of every superclass that tracks it‘s subclasses in an array returned by _subclasses_list. Classes that wish to use this functionality are required to alias the reader for their list of subclasses to _subclasses_list. Plugins for ORMs and other libraries should keep this in mind.

Parameters

const<Class>:The class to remove.

Returns

nil

:api: private

Load all classes from Merb‘s native load paths.

If fork-based loading is used, every time classes are loaded this will return in a new spawner process and boot loading will continue from this point in the boot loading process.

If fork-based loading is not in use, this only returns once and does not fork a new process.

Returns

Returns at least once:

  nil

:api: plugin

Set up the BEGIN point for fork-based loading and sets up any signals in the parent and child. This is done by forking the app. The child process continues on to run the app. The parent process waits for the child process to finish and either forks again

Returns

Parent Process:

  (Does not return.)

Child Process returns at least once:

  nil

:api: private

[Validate]