Improved ignite template deconstruct and construct functions. Simplified IgniteObject constructor.

This commit is contained in:
2023-04-24 13:39:50 -07:00
parent 018179ec56
commit 83e53ed4c3
2 changed files with 7 additions and 42 deletions

View File

@ -413,6 +413,7 @@ class IgniteProperty {
/**
* Return the value of the property if we try to convert
* the property to a string.
* @ignore
*/
IgniteProperty.prototype.toString = function () {
if (this.value) {
@ -462,24 +463,7 @@ Array.prototype.getOldPropertyValues = function (property, oldValue) {
* The outline of an IgniteObject which contains IgniteProperties.
*/
class IgniteObject {
/**
* Creates a new IgniteObject from an object and returns it.
* @param {Any} obj The object to create an IgniteObject out of.
* @returns {IgniteObject} The ignite object created.
*/
constructor(obj) {
//Only do this if the object is not an ignite object already.
if (!(obj instanceof IgniteObject)) {
Object.keys(obj).forEach(name => {
var prop = new IgniteProperty(obj[name]);
Object.defineProperty(this, name, {
get: () => { return (IgniteRendering.rendering ? prop : prop.value); },
set: (value) => { prop.value = value; }
});
});
} else {
return obj;
}
constructor() {
}
/**