2020-05-05 09:35:17 +02:00
|
|
|
export interface Assignable {
|
|
|
|
assign (a: Assignable): void;
|
|
|
|
assign_to (a: Assignable): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export abstract class Persistent {
|
|
|
|
private data: Record<string, unknown> = {};
|
|
|
|
private properties: Record<string, string>;
|
|
|
|
|
|
|
|
public constructor() {
|
|
|
|
this.properties = this.define_properties();
|
|
|
|
}
|
|
|
|
|
|
|
|
public abstract define_properties(): Record<string, string>;
|
2020-05-04 20:04:38 +02:00
|
|
|
|
|
|
|
public assign (da: Assignable): void {
|
|
|
|
this.assign_object (da.get_data ());
|
|
|
|
}
|
|
|
|
|
|
|
|
public assign_to (da: Assignable): void {
|
|
|
|
da.assign (this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public assign_object (obj: Record<string, unknown>): void {
|
|
|
|
for (const key of Object.keys (obj))
|
|
|
|
this.data[key] = obj[key];
|
|
|
|
}
|
|
|
|
|
|
|
|
public get_data (): Record<string, unknown> {
|
|
|
|
return this.data;
|
|
|
|
}
|
2020-05-05 09:35:17 +02:00
|
|
|
|
|
|
|
wip
|
2020-05-04 20:04:38 +02:00
|
|
|
}
|