Skip to content

Commit a9e4ece

Browse files
committed
Use s3_register()
1 parent 4fbfa51 commit a9e4ece

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

R/zzz.R

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,8 @@
11
# nocov start
22
.onLoad <- function(...) {
3-
register_s3_method("pillar", "pillar_shaft", "blob")
4-
register_s3_method("pillar", "is_vector_s3", "blob")
3+
s3_register("pillar::pillar_shaft", "blob")
4+
s3_register("pillar::is_vector_s3", "blob")
55

66
invisible()
77
}
8-
9-
register_s3_method <- function(pkg, generic, class, fun = NULL) {
10-
stopifnot(is.character(pkg), length(pkg) == 1)
11-
stopifnot(is.character(generic), length(generic) == 1)
12-
stopifnot(is.character(class), length(class) == 1)
13-
14-
if (is.null(fun)) {
15-
fun <- get(paste0(generic, ".", class), envir = parent.frame())
16-
} else {
17-
stopifnot(is.function(fun))
18-
}
19-
20-
if (pkg %in% loadedNamespaces()) {
21-
registerS3method(generic, class, fun, envir = asNamespace(pkg))
22-
}
23-
24-
# Always register hook in case package is later unloaded & reloaded
25-
setHook(
26-
packageEvent(pkg, "onLoad"),
27-
function(...) {
28-
registerS3method(generic, class, fun, envir = asNamespace(pkg))
29-
}
30-
)
31-
}
328
# nocov end

0 commit comments

Comments
 (0)