lib/features/hookable.js
function ( proto, parentProto ) {

        proto._initHooks = [];
        proto._destroyHooks = [];

        // add method for calling all init hooks
        proto.callInitHooks = function () {

            if ( this._initHooksCalled ) { return; }

            if ( parentProto ) {
                parentProto.callInitHooks.call(this);
            }

            this._initHooksCalled = true;

            for (var i = 0, len = proto._initHooks.length; i < len; i++) {
                proto._initHooks[i].call(this);
            }
        };

        // add method for calling all destroy hooks
        proto.callDestroyHooks = function () {

            if ( this._destroyHooksCalled ) { return; }

            if ( parentProto.callDestroyHooks ) {
                parentProto.callDestroyHooks.call(this);
            }

            this._destroyHooksCalled = true;

            for (var i = 0, len = proto._destroyHooks.length; i < len; i++) {
                proto._destroyHooks[i].call(this);
            }
        };

    }
function ( proto, parentProto ) {

        proto._initHooks = [];
        proto._destroyHooks = [];

        // add method for calling all init hooks
        proto.callInitHooks = function () {

            if ( this._initHooksCalled ) { return; }

            if ( parentProto ) {
                parentProto.callInitHooks.call(this);
            }

            this._initHooksCalled = true;

            for (var i = 0, len = proto._initHooks.length; i < len; i++) {
                proto._initHooks[i].call(this);
            }
        };

        // add method for calling all destroy hooks
        proto.callDestroyHooks = function () {

            if ( this._destroyHooksCalled ) { return; }

            if ( parentProto.callDestroyHooks ) {
                parentProto.callDestroyHooks.call(this);
            }

            this._destroyHooksCalled = true;

            for (var i = 0, len = proto._destroyHooks.length; i < len; i++) {
                proto._destroyHooks[i].call(this);
            }
        };

    }
Private functions