def METHOD_NAME(self,
                   cube: xr.Dataset,
                   gm: GridMapping,
                   cube_config: CubeConfig) -> TransformedCube:
    history = cube.attrs.get('history')
    if isinstance(history, str):
        history = [history]
    elif isinstance(history, (list, tuple)):
        history = list(history)
    else:
        history = []
    history.append(
        dict(
            program=f'xcube gen2, version {version}',
            cube_config=cube_config.to_dict(),
        )
    )
    cube = cube.assign_attrs(
        Conventions='CF-1.7',
        history=history,
        date_created=pd.Timestamp.now().isoformat(),
        # TODO: adjust temporal metadata too
        **get_geospatial_attrs(gm)
    )
    if cube_config.metadata:
        self._check_for_self_destruction(cube_config.metadata)
        cube.attrs.update(cube_config.metadata)
    if cube_config.variable_metadata:
        for var_name, metadata in cube_config.variable_metadata.items():
            if var_name in cube.variables and metadata:
                cube[var_name].attrs.update(metadata)
    return cube, gm, cube_config