Skip to content

Commit

Permalink
move data type builder for object types to object notation
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskalmar committed Jan 30, 2021
1 parent cabe652 commit 86c45eb
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/engine/datatype/ObjectDataType.ts
@@ -1,6 +1,6 @@
import { passOrThrow, resolveFunctionMap, isMap, isFunction } from '../util';
import { isEntity } from '../entity/Entity';
import { isDataType } from './DataType';
import { DataTypeFunction, isDataType } from './DataType';
import { ComplexDataType, isComplexDataType } from './ComplexDataType';
import {
AttributesMap,
Expand Down Expand Up @@ -63,10 +63,12 @@ export class ObjectDataType extends ComplexDataType {
attributeName: string,
): AttributeBase {
if (isFunction(rawAttribute.type)) {
const rawAttributeTypeFn = rawAttribute.type as Function;
const rawAttributeTypeFn = rawAttribute.type;
rawAttribute.type = rawAttributeTypeFn({
name: attributeName,
description: rawAttribute.description,
setup: {
name: attributeName,
description: rawAttribute.description,
},
});
}

Expand Down Expand Up @@ -169,14 +171,8 @@ export const isObjectDataType = (obj: unknown): obj is ObjectDataType => {

export const buildObjectDataType = (obj: {
attributes: AttributesSetupMap | AttributesMapGenerator;
}) => {
return ({
name,
description,
}: {
name: string;
description: string;
}): ObjectDataType =>
}): DataTypeFunction => {
return ({ setup: { name, description } }): ObjectDataType =>
new ObjectDataType({
description,
attributes: obj.attributes,
Expand Down

0 comments on commit 86c45eb

Please sign in to comment.