lib/function_inheritance.js
function getNamespace(namespace) {

		var result,
		    name,
		    data;

		// Try getting the namespace
		if (!namespace) {
			result = Blast.Classes;
		} else {
			result = Obj.path(Blast.Classes, namespace);
		}

		if (result == null) {
			name = namespace.split('.');
			name = name[name.length - 1];

			result = Collection.Function.create(name, function() {
				var instance;

				if (!result[name]) {
					throw new Error('Could not find class "' + name + '" in namespace "' + namespace + '"');
				}

				// Create the object instance
				instance = Object.create(result[name].prototype);

				// Apply the constructor
				result[name].apply(instance, arguments);

				return instance;
			});

			// Add a getter to get the main class of this namespace
			Blast.defineGet(result, 'main_class', function getMainClass() {
				return result[name];
			});

			// Remember this is a namespace
			result.is_namespace = true;

			// Create the namespace object
			Obj.setPath(Blast.Classes, namespace, result);

			// Emit the creation of this namespace
			if (Blast.emit) {
				data = {
					type       : 'namespace',
					namespace  : namespace
				};

				Blast.emit(data, namespace);
			}
		}

		return result;
	}
function getNamespace(namespace) {

		var result,
		    name,
		    data;

		// Try getting the namespace
		if (!namespace) {
			result = Blast.Classes;
		} else {
			result = Obj.path(Blast.Classes, namespace);
		}

		if (result == null) {
			name = namespace.split('.');
			name = name[name.length - 1];

			result = Collection.Function.create(name, function() {
				var instance;

				if (!result[name]) {
					throw new Error('Could not find class "' + name + '" in namespace "' + namespace + '"');
				}

				// Create the object instance
				instance = Object.create(result[name].prototype);

				// Apply the constructor
				result[name].apply(instance, arguments);

				return instance;
			});

			// Add a getter to get the main class of this namespace
			Blast.defineGet(result, 'main_class', function getMainClass() {
				return result[name];
			});

			// Remember this is a namespace
			result.is_namespace = true;

			// Create the namespace object
			Obj.setPath(Blast.Classes, namespace, result);

			// Emit the creation of this namespace
			if (Blast.emit) {
				data = {
					type       : 'namespace',
					namespace  : namespace
				};

				Blast.emit(data, namespace);
			}
		}

		return result;
	}
function getNamespace ( namespace ) { var result , name , data ; // Try getting the namespace if ( ! namespace ) { result = Blast . Classes ; } else { result = Obj . path ( Blast . Classes , namespace ) ; } if ( result == null ) { name = namespace . split ( '.' ) ; name = name [ name . length - 1 ] ; result = Collection . Function . create ( name , function ( ) { var instance ; if ( ! result [ name ] ) { throw new Error ( 'Could not find class "' + name + '" in namespace "' + namespace + '"' ) ; } // Create the object instance instance = Object . create ( result [ name ] . prototype ) ; // Apply the constructor result [ name ] . apply ( instance , arguments ) ; return instance ; } ) ; // Add a getter to get the main class of this namespace Blast . defineGet ( result , 'main_class' , function getMainClass ( ) { return result [ name ] ; } ) ; // Remember this is a namespace result . is_namespace = true ; // Create the namespace object Obj . setPath ( Blast . Classes , namespace , result ) ; // Emit the creation of this namespace if ( Blast . emit ) { data = { type : 'namespace' , namespace : namespace } ; Blast . emit ( data , namespace ) ; } } return result ; }
Get a namespace object, or create it if it doesn't exist

@author   Jelle De Loecker   <jelle@develry.be>
@since    0.2.1
@version  0.6.5

@param    {String}   namespace

@return   {Object}
Get a namespace object or create it if it doesn t exist