R/as_terminator.R

Defines functions as_terminators.list as_terminators.default as_terminators as_terminator.Terminator as_terminator

Documented in as_terminator as_terminators as_terminators.default as_terminators.list as_terminator.Terminator

#' @title Convert to a Terminator
#'
#' @description
#' Convert object to a [Terminator] or a list of [Terminator].
#'
#' @param x (any)\cr
#'   Object to convert.
#' @param ... (any)\cr
#'   Additional arguments.
#'
#' @export
as_terminator = function(x, ...) { # nolint
  UseMethod("as_terminator")
}

#' @export
#' @param clone (`logical(1)`)\cr
#'   If `TRUE`, ensures that the returned object is not the same as the input `x`.
#' @rdname as_terminator
as_terminator.Terminator = function(x, clone = FALSE, ...) { # nolint
  if (isTRUE(clone)) x$clone() else x
}

#' @export
#' @rdname as_terminator
as_terminators = function(x, ...) { # nolint
  UseMethod("as_terminators")
}

#' @export
#' @rdname as_terminator
as_terminators.default = function(x, ...) { # nolint
  list(as_terminator(x, ...))
}

#' @export
#' @rdname as_terminator
as_terminators.list = function(x, ...) { # nolint
  lapply(x, as_terminator, ...)
}

Try the bbotk package in your browser

Any scripts or data that you put into this service are public.

bbotk documentation built on June 8, 2025, 11:07 a.m.