def deconstruct(self, entity: Entity) -> Dto: """ Defines a way to deconstruct (aka serialize) entity object into simple values. Simple deconstruction may just extract values from fields. Complex cases may need to use another factory to deconstruct objects of dependent types. """ data = asdict(entity) if self.mapped_fields: data = { field: value for field, value in data.items() if field in self.mapped_fields } dto = Dto(data) dto.__id__ = entity.id return dto
def dto(self, data): dto = Dto(data) dto.__id__ = 17 return dto
def dto(self, data): dto = Dto(data) dto.__id__ = 17 return dto
def insert(self, **kwargs) -> Id: id_ = self._get_id() dto = Dto(kwargs) dto.__id__ = id_ self._register[id_] = dto return id_
def insert(self, **kwargs) -> Id: id_ = self._get_id() dto = Dto(kwargs) dto.__id__ = id_ self._register[id_] = dto return id_