Skip to content
9 changes: 7 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,15 @@ select_decorators <- function(decorators, scope) {
#' @keywords internal
normalize_decorators <- function(decorators) {
if (checkmate::test_list(decorators, "teal_transform_module")) {
if (checkmate::test_names(names(decorators))) {
decorators_names <- names(decorators)[!names(decorators) %in% ""]
# Above is equivalent to decorators_names <- setdiff(names(decorators), "")
# but can return non-unique values. Non-unique values are checked in assert_decorators.
if (length(decorators_names) == 0) {
list(default = decorators)
} else if (length(decorators_names) == length(decorators)) {
lapply(decorators, list)
} else {
list(default = decorators)
stop("All decorators should either be named or unnamed.")
}
} else {
decorators
Expand Down
Loading