|
1 | 1 | # nocov start |
2 | 2 | .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") |
5 | 5 |
|
6 | 6 | invisible() |
7 | 7 | } |
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 | | -} |
32 | 8 | # nocov end |
0 commit comments