add update method to ModelObject

This commit is contained in:
Aurélien Delobelle 2017-03-26 14:46:46 +02:00
parent 6afbcb44a1
commit 485ae86a42

View file

@ -137,14 +137,23 @@ class ModelObject {
*/
from(data) {
// TODO: add restrict
$.extend(this, this.constructor.default_data, data);
this.clear();
this.update(data);
}
/**
* Update properties of this instance from data ones.
* @param {Object} data
*/
update(data) {
$.extend(this, data);
}
/**
* Clear properties to {@link Models.ModelObject.default_data|default_data}.
*/
clear() {
this.from({});
$.extend(this, this.constructor.default_data);
}