Class Package
Defined in: base.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Package()
This is not a class - the functions documented here exist on all packages
created using foodev.Package and foodev.RootPackage.
|
Method Attributes | Method Name and Description |
---|---|
Class(cname, obj)
Creates a new class under the package the function is being invoked on.
|
|
Returns the full name of the package.
|
|
Returns the name of the package the method is invoked on.
|
|
Returns parent package if one exist, otherwise returns
window . |
|
Package(subPackageName)
Creates a package underneath this current package.
|
|
RootPackage(rootPackageName)
Creates a new root package under the window scope.
|
Class Detail
Package()
This is not a class - the functions documented here exist on all packages
created using foodev.Package and foodev.RootPackage.
Method Detail
Class(cname, obj)
Creates a new class under the package the function is being invoked on. Every package
created using Package#Package will have this method for creating classes
under that package.
This method exist on all packages/subpackages created using the foodev.Package method.
// This constructs a new class at foodev.bar.Test
foodev.bar.Class( 'Test', {
initialize: function () {
// constructor
}
});
new foodev.bar.Test() instanceof foodev.bar.Test // true
// This constructs a new class and returns it.
// This allows a class to be used in a closure and remain "private".
// foodev.Test will not be available in this example. Instead MyPrivateClass
// in the current scope/closures will.
var MyPrivateClass = foodev.Class( 'Test', {
Private: true,
initialize: function () {
// constructor
}
});
- Parameters:
- {String} cname
- The name of the new class to create.
- {Object} obj
- Object containing the functions/fields to put into the new class prototype.
- {Function} obj.initialize
- A function that is used to construct new instances of the class.
- {Class} obj.Extends Optional
- A class to inherit from.
- {Boolean} obj.Private Optional, Default: false
- If set to true the class will not be exposed in the Package. It will be returned instead allowing for it to be used in a closure and thus remain 'private'.
{String}
getFullPackageName()
Returns the full name of the package.
This method exist on all packages/subpackages created using the foodev.Package method.
foodev.bar.getFullPackageName(); // 'foodev.bar'.
- Returns:
- {String} The full name of the current package.
{String}
getPackageName()
Returns the name of the package the method is invoked on.
This method exist on all packages/subpackages created using the foodev.Package and Package#Package method.
foodev.bar.getPackageName(); // 'bar'
- Returns:
- {String} The name of the package the method is invoked on.
{Package}
getPackageOwner()
Returns parent package if one exist, otherwise returns
window
.
This method exist on all packages/subpackages created using the foodev.Package method.
- Returns:
- {Package} The owning package of the current package.
Package(subPackageName)
Creates a package underneath this current package. All packages created this way
receives three functions: Package#Class, Package#Package,
Package#RootPackage which are used to create classes and further subpackages
under the current package.
This method exist on all packages/subpackages created using the foodev.Package method.
Create a package under foodev.example foodev.Package('example'); // foodev.example is now available foodev.Package('example.bar.baz') foodev.example.bar.baz is now available
- Parameters:
- {String} subPackageName
- The new package name. This can be dot notation to create deep sub packages.
RootPackage(rootPackageName)
Creates a new root package under the window scope.
Create a root package named example. foodev.RootPackage('example'); // Object example is now avaiable in the global scope.
- Parameters:
- {String} rootPackageName
- The root package name.