Closed atlas-research-amsterdam closed 2 years ago
I'm happy to consider this. Could you submit a PR?
On second thought, after reading up on S3 generics in Advanced R, I think it's better for authors of derived classes to simply write their own constructor
etl_pkgname <- function(db = NULL, dir = tempdir(), ...) {
obj <- etl("pkgname", db = db, dir = dir, ...)
# do project specific extensions here
obj
}
Overriding the various
etl_xxx.default(obj, ...)
functions for a classfoo
usingetl_xxx.foo(obj, ...)
works splendidly.However, the factory function
etl.default
itself cannot profit from this mechanism because it is called with a string and not an object, so that S3 dispatch will always call the default version.I have a project where I have split the
etl_transform
step into various other steps using helpers such asetl_parse
andetl_normalize
. For each intermediate step, I want to create a separate directory (such asparse_dir
) to cache the intermediate data frames before finally copying them toload_dir
.It would be nice if
etl.default
were to provide a hook of the formThen it becomes possible to initalize other project specific stuff (such as
parse_dir
) inside the user-definedetl.etl_foo
.