File: utils-redacted.R

package info (click to toggle)
r-cran-httr2 1.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,684 kB
  • sloc: sh: 13; makefile: 2
file content (25 lines) | stat: -rw-r--r-- 616 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
redacted_sentinel <- function() {
  structure(list(NULL), class = "httr2_redacted_sentinel")
}
#' @export
print.httr2_redacted_sentinel <- function(x, ...) {
  cat(format(x), "\n", sep = "")
  invisible(x)
}
#' @export
format.httr2_redacted_sentinel <- function(x, ...) {
  unclass(cli::col_grey("<REDACTED>"))
}
#' @export
str.httr2_redacted_sentinel <- function(object, ...) {
  cat(" ", cli::col_grey("<REDACTED>"), "\n", sep = "")
}

list_redact <- function(x, names) {
  x[names(x) %in% names] <- list(redacted_sentinel())
  x
}

is_redacted_sentinel <- function(x) {
  inherits(x, "httr2_redacted_sentinel")
}