lib/cakes.js
function Class(prop, superClass) {
        var ClassType = function() {
            function F(args) {
                for (var name in ClassType.__prop) {
                    var val = ClassType.__prop[name];
                    this[name] = isObject(val) ? extend({}, val) : val;
                }

                if (isFunction(this.__construct)) {
                    this.__construct.apply(this, [].slice.call(args));
                }

                return this;
            }

            F.prototype = ClassType.prototype;
            F.constructor = ClassType;
            return new F(arguments);
        };

        ClassType.extend = function(prop) {
            if (isFunction(prop)) {
                prop = prop();
            }

            if (isObject(prop)) {
                for (var name in prop) {
                    var val = prop[name];

                    if (name === 'parent') {
                        throw new Error("'parent' method must not be override wrote.");
                    }

                    if (isFunction(val)) {
                        ClassType.prototype[name] = val;
                    } else {
                        ClassType.__prop[name] = isObject(val) ? extend({}, val) : val;
                    }
                }
            }

            return this;
        };

        ClassType.inherits = function(superClass) {
            inherits(ClassType, superClass);
            extend(ClassType.__prop, superClass.__prop);

            return this;
        };

        ClassType.prototype.parent = function(methodName, args) {
            var super_ = this.constructor.super_;
            if (!isFunction(this[methodName]) || !isFunction(super_.prototype[methodName])) {
                throw new Error("parent has not method '" + methodName + "'.");
            }

            if (arguments.length === 1) {
                args = [];
            } else if (!isArray(args)) {
                args = [].slice.call(arguments, 1);
            }

            while ((this[methodName] === super_.prototype[methodName]) && super_.super_) {
                super_ = super_.super_;
            }

            var method = super_.prototype[methodName];
            delete super_.prototype[methodName];
            var retResult = method.apply(this, args);
            super_.prototype[methodName] = method;

            return retResult;
        };

        ClassType.__prop = {};
        if (superClass === true && isFunction(prop)) {
            superClass = prop;
            prop = undefined;
        }

        if (isFunction(superClass)) {
            ClassType.inherits(superClass);
        }

        if (prop) {
            ClassType.extend(prop);
        }

        return ClassType;
    }
function Class(prop, superClass) {
        var ClassType = function() {
            function F(args) {
                for (var name in ClassType.__prop) {
                    var val = ClassType.__prop[name];
                    this[name] = isObject(val) ? extend({}, val) : val;
                }

                if (isFunction(this.__construct)) {
                    this.__construct.apply(this, [].slice.call(args));
                }

                return this;
            }

            F.prototype = ClassType.prototype;
            F.constructor = ClassType;
            return new F(arguments);
        };

        ClassType.extend = function(prop) {
            if (isFunction(prop)) {
                prop = prop();
            }

            if (isObject(prop)) {
                for (var name in prop) {
                    var val = prop[name];

                    if (name === 'parent') {
                        throw new Error("'parent' method must not be override wrote.");
                    }

                    if (isFunction(val)) {
                        ClassType.prototype[name] = val;
                    } else {
                        ClassType.__prop[name] = isObject(val) ? extend({}, val) : val;
                    }
                }
            }

            return this;
        };

        ClassType.inherits = function(superClass) {
            inherits(ClassType, superClass);
            extend(ClassType.__prop, superClass.__prop);

            return this;
        };

        ClassType.prototype.parent = function(methodName, args) {
            var super_ = this.constructor.super_;
            if (!isFunction(this[methodName]) || !isFunction(super_.prototype[methodName])) {
                throw new Error("parent has not method '" + methodName + "'.");
            }

            if (arguments.length === 1) {
                args = [];
            } else if (!isArray(args)) {
                args = [].slice.call(arguments, 1);
            }

            while ((this[methodName] === super_.prototype[methodName]) && super_.super_) {
                super_ = super_.super_;
            }

            var method = super_.prototype[methodName];
            delete super_.prototype[methodName];
            var retResult = method.apply(this, args);
            super_.prototype[methodName] = method;

            return retResult;
        };

        ClassType.__prop = {};
        if (superClass === true && isFunction(prop)) {
            superClass = prop;
            prop = undefined;
        }

        if (isFunction(superClass)) {
            ClassType.inherits(superClass);
        }

        if (prop) {
            ClassType.extend(prop);
        }

        return ClassType;
    }
function Class ( prop , superClass ) { var ClassType = function ( ) { function F ( args ) { for ( var name in ClassType . __prop ) { var val = ClassType . __prop [ name ] ; this [ name ] = isObject ( val ) ? extend ( { } , val ) : val ; } if ( isFunction ( this . __construct ) ) { this . __construct . apply ( this , [ ] . slice . call ( args ) ) ; } return this ; } F . prototype = ClassType . prototype ; F . constructor = ClassType ; return new F ( arguments ) ; } ; ClassType . extend = function ( prop ) { if ( isFunction ( prop ) ) { prop = prop ( ) ; } if ( isObject ( prop ) ) { for ( var name in prop ) { var val = prop [ name ] ; if ( name === 'parent' ) { throw new Error ( "'parent' method must not be override wrote." ) ; } if ( isFunction ( val ) ) { ClassType . prototype [ name ] = val ; } else { ClassType . __prop [ name ] = isObject ( val ) ? extend ( { } , val ) : val ; } } } return this ; } ; ClassType . inherits = function ( superClass ) { inherits ( ClassType , superClass ) ; extend ( ClassType . __prop , superClass . __prop ) ; return this ; } ; ClassType . prototype . parent = function ( methodName , args ) { var super_ = this . constructor . super_ ; if ( ! isFunction ( this [ methodName ] ) || ! isFunction ( super_ . prototype [ methodName ] ) ) { throw new Error ( "parent has not method '" + methodName + "'." ) ; } if ( arguments . length === 1 ) { args = [ ] ; } else if ( ! isArray ( args ) ) { args = [ ] . slice . call ( arguments , 1 ) ; } while ( ( this [ methodName ] === super_ . prototype [ methodName ] ) && super_ . super_ ) { super_ = super_ . super_ ; } var method = super_ . prototype [ methodName ] ; delete super_ . prototype [ methodName ] ; var retResult = method . apply ( this , args ) ; super_ . prototype [ methodName ] = method ; return retResult ; } ; ClassType . __prop = { } ; if ( superClass === true && isFunction ( prop ) ) { superClass = prop ; prop = undefined ; } if ( isFunction ( superClass ) ) { ClassType . inherits ( superClass ) ; } if ( prop ) { ClassType . extend ( prop ) ; } return ClassType ; }
Create a class construct function.
@param  {Function} prop       Custom properties of class
@param  {Function} superClass Super class
@return {Function}            New class construct function
Create a class construct function .