{"size": 3208, "ext": "js", "max_stars_repo_path": "src/define/class/build.js", "max_stars_repo_name": "ArnaudBuchholz/gpf-js", "max_stars_repo_stars_event_min_datetime": "2015-05-15T18:42:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-03T23:03:32.000Z", "max_issues_repo_path": "src/define/class/build.js", "max_issues_repo_name": "ArnaudBuchholz/gpf-js", "max_issues_repo_issues_event_min_datetime": "2015-01-28T00:04:32.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-08T00:45:14.000Z", "max_forks_repo_path": "src/define/class/build.js", "max_forks_repo_name": "ArnaudBuchholz/gpf-js", "max_forks_repo_forks_event_min_datetime": "2019-06-19T16:41:22.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-02T15:41:50.000Z"}
{"max_stars_count": 14, "max_issues_count": 301, "max_forks_count": 4, "avg_line_length": 32.08, "max_line_length": 115, "alphanum_fraction": 0.6246882793}
/**
 * @file Build class
 * @since 0.1.6
 */
/*#ifndef(UMD)*/
"use strict";
/*global _GpfClassDefinition*/ // Class definition
/*global _gpfDefineGetClassSecuredConstructor*/ // Allocate a secured named constructor
/*global _gpfObjectForEach*/ // Similar to [].forEach but for objects
/*#endif*/

Object.assign(_GpfClassDefinition.prototype, {

    /**
     * @inheritdoc
     * @since 0.1.6
     */
    _build: function () {
        var newClass,
            newPrototype;
        this._resolveConstructor();
        newClass = _gpfDefineGetClassSecuredConstructor(this);
        // Basic JavaScript inheritance mechanism: Defines the newClass prototype as an instance of the super class
        newPrototype = Object.create(this._extend.prototype);
        // Populate our constructed prototype object
        newClass.prototype = newPrototype;
        // Enforce the constructor to be what we expect
        newPrototype.constructor = newClass;
        this._buildPrototype(newPrototype);
        return newClass;
    },

    /**
     * Add method to the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @param {String} methodName Method name
     * @param {Function} method Method
     * @since 0.1.7
     */
    _addMethodToPrototype: function (newPrototype, methodName, method) {
        newPrototype[methodName] = this._superify(method, methodName);
    },

    /**
     * Add member to the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @param {String} memberName Member name
     * @param {*} value Member value
     * @since 0.1.7
     */
    _addMemberToPrototype: function (newPrototype, memberName, value) {
        if (typeof value === "function") {
            this._addMethodToPrototype(newPrototype, memberName, value);
        } else {
            newPrototype[memberName] = value;
        }
    },

    /**
     * Build the new class prototype
     *
     * @param {Object} newPrototype New class prototype
     * @since 0.1.7
     */
    _buildPrototype: function (newPrototype) {
        _gpfObjectForEach(this._initialDefinition, function (value, memberName) {
            if (!memberName.startsWith("$") && memberName !== "constructor") {
                this._addMemberToPrototype(newPrototype, memberName, value); //eslint-disable-line no-invalid-this
            }
        }, this);
    },

    /**
     * Set the inherited constructor if not Object
     * @since 0.1.7
     */
    _setResolvedConstructorToInherited: function () {
        if (this._extend !== Object) {
            this._resolvedConstructor = this._extend;
        }
    },

    /**
     * Assign the proper constructor to _resolvedConstructor
     * @since 0.1.7
     */
    _resolveConstructor: function () {
        if (Object.prototype.hasOwnProperty.call(this._initialDefinition, "constructor")) {
            /* jshint -W069*/ /*eslint-disable dot-notation*/
            this._resolvedConstructor = this._superify(this._initialDefinition["constructor"], "constructor");
            /* jshint +W069*/ /*eslint-enable dot-notation*/
        } else {
            this._setResolvedConstructorToInherited();
        }
    }

});
