refactor: loadOrInstance -> Resource
This commit is contained in:
parent
ea57d21efc
commit
5b1b9442c7
|
@ -105,17 +105,6 @@ export class Entity extends decorate(Resource) {
|
||||||
return pristine;
|
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) {
|
constructor(json, jsonext) {
|
||||||
super();
|
super();
|
||||||
this._hooks = {};
|
this._hooks = {};
|
||||||
|
|
|
@ -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) {
|
static read(uri) {
|
||||||
if (!this.readCache) {
|
if (!this.readCache) {
|
||||||
this.readCache = {};
|
this.readCache = {};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user