Account for duplicate copies without populating more than once. As a result, populate in place.

This commit is contained in:
Erik Erikson 2017-11-17 17:30:15 -08:00
parent e823679340
commit 143a2aa65b

View File

@ -99,8 +99,10 @@ class Variables {
} else {
singleValueToPopulate = this.getValueFromSource(variableString)
.then(valueToPopulate => {
if (typeof valueToPopulate === 'object'
&& typeof this.populatedObjectReferences[variableString] === 'undefined') {
if (typeof valueToPopulate === 'object') {
if (variableString in this.populatedObjectReferences) {
return this.populatedObjectReferences[variableString];
}
this.populatedObjectReferences[variableString] = valueToPopulate;
return this.populateObject(valueToPopulate);
}
@ -121,7 +123,7 @@ class Variables {
});
return BbPromise.all(allValuesToPopulate).then(() => {
if (property !== this.service) {
return this.populateProperty(property);
return this.populateProperty(property, true);
}
return BbPromise.resolve(property);
});
@ -402,7 +404,7 @@ class Variables {
}
if (typeof computedValueToPopulate === 'string' &&
computedValueToPopulate.match(this.variableSyntax)) {
return this.populateProperty(computedValueToPopulate);
return this.populateProperty(computedValueToPopulate, true);
}
return BbPromise.resolve(computedValueToPopulate);
}, valueToPopulate);