mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-13 06:57:28 +08:00
Simple serialization entities fixes and tests
This commit is contained in:
@@ -10,6 +10,7 @@ import Union from "./Union.js"
|
||||
/** @abstract */
|
||||
export default class IEntity extends Serializable {
|
||||
|
||||
/** @type {{ [attribute: String]: AttributeInfo }} */
|
||||
static attributes = {
|
||||
attributes: new AttributeInfo({
|
||||
ignored: true,
|
||||
@@ -147,21 +148,6 @@ export default class IEntity extends Serializable {
|
||||
return value != null && (value instanceof type || value.constructor === type)
|
||||
}
|
||||
|
||||
static expectsAllKeys() {
|
||||
return !Object.values(this.attributes)
|
||||
.filter(/** @param {AttributeInformation} attribute */attribute => !attribute.ignored)
|
||||
.some(/** @param {AttributeInformation} attribute */attribute => !attribute.expected)
|
||||
}
|
||||
|
||||
static getAttribute(object, attribute) {
|
||||
return this.getAttributes(object)[attribute]
|
||||
}
|
||||
|
||||
/** @returns {AttributeDeclarations} */
|
||||
static getAttributes(object) {
|
||||
return object.attributes ?? object.constructor?.attributes ?? {}
|
||||
}
|
||||
|
||||
static defineAttributes(object, attributes) {
|
||||
Object.defineProperty(object, "attributes", {
|
||||
writable: true,
|
||||
|
||||
Reference in New Issue
Block a user