Skip to content

Commit

Permalink
Improves maintainability (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Feb 16, 2018
1 parent 8b92eef commit 37f24e4
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/define/class/attributes/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
/*#ifndef(UMD)*/
"use strict";
/*global _GpfClassDefinition*/ // Class definition
/*global _gpfDefineClassAttributesIsAttributeSpecification*/ // Check if member name is an attribute
/*global _GPF_DEFINE_CLASS_ATTRIBUTES_SPEFICIATION*/ // $attributes
/*global _gpfDefClassAttrIsAttributeSpecification*/ // Check if member name is an attribute
/*global _GPF_DEFINE_CLASS_ATTRIBUTES_SPECIFICATION*/ // $attributes
/*#endif*/

var _gpfDefineClassAttributesClassAddmemberToPrototype = _GpfClassDefinition.prototype._addMemberToPrototype,
_gpfDefineClassAttributesClassBuildPrototype = _GpfClassDefinition.prototype._buildPrototype;
var _gpfDefClassAttrClassAddmemberToPrototype = _GpfClassDefinition.prototype._addMemberToPrototype,
_gpfDefClassAttrClassBuildPrototype = _GpfClassDefinition.prototype._buildPrototype,
_gpfDefClassAttrClassMemberName = "$" + _GPF_DEFINE_CLASS_ATTRIBUTES_SPECIFICATION;

Object.assign(_GpfClassDefinition.prototype, {

Expand All @@ -19,30 +20,27 @@ Object.assign(_GpfClassDefinition.prototype, {
_attributes: {},

_addAttributesFor: function (memberName, attributes) {
if (!this.hasOwnProperty(this._attributes)) {
this._attributes = {};
}
this._attributes[memberName] = attributes;
},

/** @inheritdoc */
_addMemberToPrototype: function (newPrototype, memberName, value) {
var attributeName = _gpfDefineClassAttributesIsAttributeSpecification(memberName);
var attributeName = _gpfDefClassAttrIsAttributeSpecification(memberName);
if (attributeName) {
this._addAttributesFor(attributeName, value);
} else {
_gpfDefineClassAttributesClassAddmemberToPrototype.call(this, newPrototype, memberName, value);
_gpfDefClassAttrClassAddmemberToPrototype.call(this, newPrototype, memberName, value);
}
},

/** @inheritdoc */
_buildPrototype: function (newPrototype) {
var classAttributesMember = "$" + _GPF_DEFINE_CLASS_ATTRIBUTES_SPEFICIATION,
classAttributes = this._initialDefinition[classAttributesMember];
var classAttributes = this._initialDefinition[_gpfDefClassAttrClassMemberName];
this._attributes = {};
if (classAttributes) {
this._addAttributesFor(classAttributesMember, classAttributes);
this._addAttributesFor(_gpfDefClassAttrClassMemberName, classAttributes);
}
_gpfDefineClassAttributesClassBuildPrototype.call(this, newPrototype);
_gpfDefClassAttrClassBuildPrototype.call(this, newPrototype);
}

});

0 comments on commit 37f24e4

Please sign in to comment.