Classes Class
Pollyfils for often used functionality for Functions Copyright (c) 2014 ITSA - https://github.com/itsa New BSD License - http://choosealicense.com/licenses/bsd-3-clause/
Item Index
Methods
Methods
_destroy
()
private
chainable
Transformed from destroy
--> when destroy
gets invoked, the instance will invoke _destroy
through the whole chain.
Defaults to NOOP
, so that it can be always be invoked.
afterInit
()
private
chainable
Transformed from destroy
--> when destroy
gets invoked, the instance will invoke _destroy
through the whole chain.
Defaults to NOOP
, so that it can be always be invoked.
createBaseClass
()
Class
protected
Creates the base Class: the highest Class in the hierarchy of all Classes.
Will get extra properties merge into its prototype, which leads into the formation of BaseClass
.
Returns:
createClass
-
[constructor]
-
[prototype]
Returns a base class with the given constructor and prototype methods
Parameters:
Returns:
the new class
defineProperties
-
[object]
-
[map]
-
[force=false]
Sugarmethod for using defineProperty for multiple properties at once.
defineProperty
-
[object]
-
[name]
-
[method]
-
[force=false]
Sugarmethod for Object.defineProperty creating an unenumerable property
destroy
-
[notChained=false]
Calls _destroy
on through the class-chain on every level (bottom-up).
_destroy gets defined when the itag defines destroy
--> transformation under the hood.
Parameters:
-
[notChained=false]
Boolean optionalset this
true
to prevent callingdestroy
up through the chain
mergePrototypes
-
prototypes
-
force
Merges the given prototypes of properties into the prototype
of the Class.
Note1 to be used on instances --> ONLY on Classes Note2 properties with getters and/or unwritable will NOT be merged
The members in the hash prototypes will become members with instances of the merged class.
By default, this method will not override existing prototype members,
unless the second argument force
is true.
NOOP
()
protected
Empty function
removePrototypes
-
properties
Removes the specified prototypes from the Class.
setConstructor
-
[constructorFn]
-
[prototypes]
-
[chainConstruct=true]
Redefines the constructor fo the Class
Parameters:
-
[constructorFn]
Function optionalThe function that will serve as the new constructor for the class. If
undefined
defaults toNOOP
-
[prototypes]
Object optionalHash map of properties to be added to the prototype of the new class.
-
[chainConstruct=true]
Boolean optionalWhether -during instance creation- to automaticly construct in the complete hierarchy with the given constructor arguments.
subClass
-
[constructor]
-
[prototypes]
-
[chainConstruct=true]
Returns a newly created class inheriting from this class
using the given constructor
with the
prototypes listed in prototypes
merged in.
The newly created class has the $$super
static property
available to access all of is ancestor's instance methods.
Further methods can be added via the mergePrototypes.
Parameters:
-
[constructor]
Function optionalThe function that will serve as constructor for the new class. If
undefined
defaults toNOOP
-
[prototypes]
Object optionalHash map of properties to be added to the prototype of the new class.
-
[chainConstruct=true]
Boolean optionalWhether -during instance creation- to automaticly construct in the complete hierarchy with the given constructor arguments.
Returns:
the new class.
Example:
var Circle = Shape.subClass( function (x, y, r) { // arguments will automaticly be passed through to Shape's constructor this.r = r; }, { area: function () { return this.r this.r Math.PI; } } );
Properties
BaseClass
Class
The base BaseClass: the highest Class in the hierarchy of all Classes.
DEFAULT_CHAIN_CONSTRUCT
Boolean
protected
Defines whether Classes should call their constructor in a chained way top-down.
Default: true
PROTECTED_CLASS_METHODS
Object
protected
Internal hash containing protected members: those who cannot be merged into a Class
Default: {$super: true, $superProp: true, $orig: true}
REPLACE_CLASS_METHODS
Object
protected
Internal hash containing the names of members which names should be transformed
Default: {destroy: '_destroy'}