R/secret.R

Defines functions as.data.frame.rsconnect_secret str.rsconnect_secret print.rsconnect_secret format.rsconnect_secret secret

secret <- function(x) {
  if (is.null(x)) return(NULL)

  stopifnot(is.character(x) || all(is.na(x)))
  structure(x, class = "rsconnect_secret")
}

#' @export
format.rsconnect_secret <- function(x, ...) {
  paste0(substr(x, 1, 6), "... (redacted)")
}

#' @export
print.rsconnect_secret <- function(x, ...) {
  print(format(x))
  invisible(x)
}

#' @export
str.rsconnect_secret <- function(object, ...) {
  cat(" ", format(object), "\n", sep = "")
}

#' @export
as.data.frame.rsconnect_secret <- function(x,
                                           ...) {
  structure(
    list(x),
    row.names = .set_row_names(length(x)),
    class = "data.frame"
  )
}

Try the rsconnect package in your browser

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

rsconnect documentation built on Oct. 30, 2024, 9:11 a.m.