refactor: loadOrInstance -> Resource

This commit is contained in:
cha0s 2019-09-16 19:04:02 -05:00
parent ea57d21efc
commit 5b1b9442c7
2 changed files with 11 additions and 11 deletions

View File

@ -105,17 +105,6 @@ export class Entity extends decorate(Resource) {
return pristine;
}
static loadOrInstance(json) {
if (json.uri) {
return Entity.read(json.uri).then((entityJSON) => {
return new Entity(entityJSON, json);
});
}
else {
return Promise.resolve(new Entity(json));
}
}
constructor(json, jsonext) {
super();
this._hooks = {};

View File

@ -31,6 +31,17 @@ export class Resource extends decorate(class {}) {
});
}
static loadOrInstance(json) {
if (json.uri) {
return this.read(json.uri).then((readJson) => {
return new this(readJson, json);
});
}
else {
return Promise.resolve(new this(json));
}
}
static read(uri) {
if (!this.readCache) {
this.readCache = {};