Skip to content

Commit

Permalink
Exposes shared method (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Feb 16, 2018
1 parent 723b638 commit fef5e4b
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/define/class/attributes/check.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file Attributes management in a class
* @file Check attributes definition in a class
*/
/*#ifndef(UMD)*/
"use strict";
Expand All @@ -8,6 +8,8 @@
/*global _GpfClassDefinition*/ // Class definition
/*global _gpfErrorDeclare*/ // Declare new gpf.Error names
/*global _gpfIsArrayLike*/
/*exported _GPF_DEFINE_CLASS_ATTRIBUTES_SPEFICIATION*/ // $attributes
/*exported _gpfDefineClassAttributesIsAttributeSpecification*/ // Check if member name is an attribute
/*#endif*/

// Done as a feature 'on top' of normal class definition to be able to remove it easily
Expand Down Expand Up @@ -38,27 +40,25 @@ _gpfErrorDeclare("define/class/attributes", {

});

//region define/class/check

var _GPF_DEFINE_CLASS_ATTRIBUTES_SPEFICIATION = "attributes",
_gpfDefineClassAttributesClassCheckMemberName = _GpfClassDefinition.prototype._checkMemberName,
_gpfDefineClassAttributesClassCheckMemberValue = _GpfClassDefinition.prototype._checkMemberValue,
_gpfDefineClassAttributesClassCheck$Property = _GpfClassDefinition.prototype._check$Property;

Object.assign(_GpfClassDefinition.prototype, {
/**
* Given the member name, tells if the property introduces attributes
*
* @param {String} name Member name
* @return {String|undefined} Real property name if attributes specification, undefined otherwise
*/
function _gpfDefineClassAttributesIsAttributeSpecification (name) {
var length = name.length;
if (name.charAt(0) === "[" && name.charAt(length - 1) === "]") {
return name.substr(1, length - 2);
}
}

/**
* Given the member name, tells if the property introduces attributes
*
* @param {String} name Member name
* @return {String|undefined} Real property name if attributes specification, undefined otherwise
*/
_isAttributeSpecification: function (name) {
var length = name.length;
if (name.charAt(0) === "[" && name.charAt(length - 1) === "]") {
return name.substr(1, length - 2);
}
},
Object.assign(_GpfClassDefinition.prototype, {

/**
* Given the member name, tells if it exists
Expand All @@ -75,7 +75,7 @@ Object.assign(_GpfClassDefinition.prototype, {

/** @inheritdoc */
_checkMemberName: function (name) {
var attributeName = this._isAttributeSpecification(name);
var attributeName = _gpfDefineClassAttributesIsAttributeSpecification(name);
if (attributeName) {
_gpfDefineClassAttributesClassCheckMemberName.call(this, attributeName);
this._checkMemberExist(attributeName);
Expand Down Expand Up @@ -105,7 +105,7 @@ Object.assign(_GpfClassDefinition.prototype, {

/** @inheritdoc */
_checkMemberValue: function (name, value) {
if (this._isAttributeSpecification(name)) {
if (_gpfDefineClassAttributesIsAttributeSpecification(name)) {
this._checkAttributesSpecification(value);
} else {
_gpfDefineClassAttributesClassCheckMemberValue.call(this, name, value);
Expand All @@ -124,5 +124,3 @@ Object.assign(_GpfClassDefinition.prototype, {
});

_GpfClassDefinition.prototype._allowed$Properties.push(_GPF_DEFINE_CLASS_ATTRIBUTES_SPEFICIATION);

//endregion

0 comments on commit fef5e4b

Please sign in to comment.