ring.js
function toRingClass(claz) {
        if (claz.__classId__)
            return;
        var proto = ! Object.getOwnPropertyNames ? claz.prototype : (function() {
            var keys = {};
            (function crawl(p) {
                if (p === Object.prototype)
                    return;
                _.extend(keys, _.chain(Object.getOwnPropertyNames(p))
                    .map(function(el) {return [el, true];})
                    .fromPairs().value());
                crawl(Object.getPrototypeOf(p));
            })(claz.prototype);
            return _.fromPairs(_.map(_.keys(keys), function(k) {return [k, claz.prototype[k]];}));
        })();
        proto = _.chain(proto).map(function(v, k) { return [k, v]; })
            .filter(function(el) {return el[0] !== "constructor" && el[0] !== "__proto__";})
            .fromPairs().value();
        var id = classCounter++;
        _.extend(claz, {
            __mro__: [claz, ring.Object],
            __properties__: _.extend({}, proto, {
                __ringConstructor__: function() {
                    this.$super.apply(this, arguments);
                    var tmp = this.$super;
                    this.$super = null;
                    try {
                        claz.apply(this, arguments);
                    } finally {
                        this.$super = tmp;
                    }
                }
            }),
            __classId__: id,
            __parents__: [ring.Object],
            __classIndex__: {"1": ring.Object},
            __ringConvertedObject__: true
        });
        claz.__classIndex__[id] = claz;
    }
function toRingClass(claz) {
        if (claz.__classId__)
            return;
        var proto = ! Object.getOwnPropertyNames ? claz.prototype : (function() {
            var keys = {};
            (function crawl(p) {
                if (p === Object.prototype)
                    return;
                _.extend(keys, _.chain(Object.getOwnPropertyNames(p))
                    .map(function(el) {return [el, true];})
                    .fromPairs().value());
                crawl(Object.getPrototypeOf(p));
            })(claz.prototype);
            return _.fromPairs(_.map(_.keys(keys), function(k) {return [k, claz.prototype[k]];}));
        })();
        proto = _.chain(proto).map(function(v, k) { return [k, v]; })
            .filter(function(el) {return el[0] !== "constructor" && el[0] !== "__proto__";})
            .fromPairs().value();
        var id = classCounter++;
        _.extend(claz, {
            __mro__: [claz, ring.Object],
            __properties__: _.extend({}, proto, {
                __ringConstructor__: function() {
                    this.$super.apply(this, arguments);
                    var tmp = this.$super;
                    this.$super = null;
                    try {
                        claz.apply(this, arguments);
                    } finally {
                        this.$super = tmp;
                    }
                }
            }),
            __classId__: id,
            __parents__: [ring.Object],
            __classIndex__: {"1": ring.Object},
            __ringConvertedObject__: true
        });
        claz.__classIndex__[id] = claz;
    }
function toRingClass ( claz ) { if ( claz . __classId__ ) return ; var proto = ! Object . getOwnPropertyNames ? claz . prototype : ( function ( ) { var keys = { } ; ( function crawl ( p ) { if ( p === Object . prototype ) return ; _ . extend ( keys , _ . chain ( Object . getOwnPropertyNames ( p ) ) . map ( function ( el ) { return [ el , true ] ; } ) . fromPairs ( ) . value ( ) ) ; crawl ( Object . getPrototypeOf ( p ) ) ; } ) ( claz . prototype ) ; return _ . fromPairs ( _ . map ( _ . keys ( keys ) , function ( k ) { return [ k , claz . prototype [ k ] ] ; } ) ) ; } ) ( ) ; proto = _ . chain ( proto ) . map ( function ( v , k ) { return [ k , v ] ; } ) . filter ( function ( el ) { return el [ 0 ] !== "constructor" && el [ 0 ] !== "__proto__" ; } ) . fromPairs ( ) . value ( ) ; var id = classCounter ++ ; _ . extend ( claz , { __mro__ : [ claz , ring . Object ] , __properties__ : _ . extend ( { } , proto , { __ringConstructor__ : function ( ) { this . $super . apply ( this , arguments ) ; var tmp = this . $super ; this . $super = null ; try { claz . apply ( this , arguments ) ; } finally { this . $super = tmp ; } } } ) , __classId__ : id , __parents__ : [ ring . Object ] , __classIndex__ : { "1" : ring . Object } , __ringConvertedObject__ : true } ) ; claz . __classIndex__ [ id ] = claz ; }
Convert an existing class to be used with the ring.js class system.
Convert an existing class to be used with the ring . js class system .