Skip to content
Permalink
Browse files

potential fix for S3 madness

  • Loading branch information...
topepo committed Sep 3, 2019
1 parent 6b9aa44 commit 593d0e8078512b2fe36b0fbae14560034519cd06
Showing with 3 additions and 42 deletions.
  1. +1 −1 DESCRIPTION
  2. +1 −1 NAMESPACE
  3. +1 −1 R/0.R
  4. +0 −39 R/s3_register.R
@@ -37,5 +37,5 @@ Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
Remotes:
tidymodels/recipes,
tidymodels/hardhat
tidymodels/hardhat@b5df2d6
VignetteBuilder: knitr
@@ -29,7 +29,6 @@ export(apd_pca)
export(apd_similarity)
export(autoplot.apd_pca)
export(autoplot.apd_similarity)
export(s3_register)
export(score)
export(score.default)
importFrom(Matrix,Matrix)
@@ -47,6 +46,7 @@ importFrom(dplyr,slice)
importFrom(dplyr,starts_with)
importFrom(dplyr,ungroup)
importFrom(ggplot2,aes)
importFrom(ggplot2,autoplot)
importFrom(ggplot2,geom_step)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,xlab)
2 R/0.R
@@ -28,7 +28,7 @@
#' @importFrom hardhat forge
#' @importFrom hardhat mold
#' @importFrom hardhat new_model
#' @importFrom ggplot2 ggplot geom_step xlab ylab aes
#' @importFrom ggplot2 ggplot geom_step xlab ylab aes autoplot
#' @importFrom Matrix Matrix colSums
#' @importFrom tidyselect vars_select
#' @importFrom tidyr gather
@@ -1,42 +1,3 @@
#' Register a method for a suggested dependency
#'
#' Generally, the recommend way to register an S3 method is to use the
#' `S3Method()` namespace directive (often generated automatically be the
#' `@export` roxygen2 tag). However, this technique requires that the generic
#' be in an imported package, and sometimes you want to suggest a package,
#' and only provide a method when that package is loaded. `s3_register()`
#' can be called from your package's `.onLoad()` to dynamically register
#' a method only if the generic's package is loaded. (To avoid taking a
#' dependency on vctrs for this one function, please feel free to copy
#' and paste the function source into your own package.)
#'
#' For R 3.5.0 and later, `s3_register()` is also useful when demonstrating
#' class creation in a vignette, since method lookup no longer always involves
#' the lexical scope. For R 3.6.0 and later, you can achieve a similar effect
#' by using "delayed method registration", i.e. placing the following in your
#' `NAMESPACE` file:
#'
#' ```
#' if (getRversion() >= "3.6.0") {
#' S3method(package::generic, class)
#' }
#' ```
#'
#' @param generic Name of the generic in the form `pkg::generic`.
#' @param class Name of the class
#' @param method Optionally, the implementation of the method. By default,
#' this will be found by looking for a function called `generic.class`
#' in the package environment.
#'
#' Note that providing `method` can be dangerous if you use
#' devtools. When the namespace of the method is reloaded by
#' `devtools::load_all()`, the function will keep inheriting from
#' the old namespace. This might cause crashes because of dangling
#' `.Call()` pointers.
#' @export
#' @noRd
#' @keywords internal
# from https://raw.githubusercontent.com/r-lib/vctrs/master/R/register-s3.R
# nocov start
s3_register <- function(generic, class, method = NULL) {
stopifnot(is.character(generic), length(generic) == 1)

0 comments on commit 593d0e8

Please sign in to comment.
You can’t perform that action at this time.