Skip to content

Commit

Permalink
Fix method registration of cast methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Nov 6, 2020
1 parent 46a46ce commit 3155367
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
11 changes: 6 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ S3method(select,vitae_preserve)
S3method(slice,vitae_preserve)
S3method(summarise,vitae_preserve)
S3method(transmute,vitae_preserve)
S3method(vec_cast.character,csl_date)
S3method(vec_cast.character,csl_name)
S3method(vec_cast.double,csl_date)
S3method(vec_proxy_order,csl_date)
S3method(vec_proxy_order,csl_name)
S3method(vec_ptype2,csl_date.double)
S3method(vec_ptype2.double,csl_date)
S3method(vec_ptype_abbr,csl_date)
S3method(vec_ptype_abbr,csl_name)
S3method(xtfrm,csl_date)
Expand All @@ -46,12 +51,8 @@ export(slice)
export(summarise)
export(transmute)
export(twentyseconds)
export(vec_cast.character.csl_date)
export(vec_cast.character.csl_name)
export(vec_cast.double.csl_date)
export(vec_ptype2.csl_date.double)
export(vec_ptype2.double.csl_date)
import(glue)
import(vctrs)
importFrom(dplyr,"%>%")
importFrom(dplyr,arrange)
importFrom(dplyr,distinct)
Expand Down
4 changes: 4 additions & 0 deletions R/csl_types.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ format.csl_name <- function(x, ...) {
#' @export
vec_ptype_abbr.csl_name <- function(x) "csl name"

#' @method vec_cast.character csl_name
#' @export
vec_cast.character.csl_name <- function(x, to, ...) {
format(x)
Expand Down Expand Up @@ -97,13 +98,16 @@ vec_ptype_abbr.csl_date <- function(x) "csl_date"
vec_ptype2.csl_date.double <- function(x, y, ...) {
double()
}
#' @method vec_ptype2.double csl_date
#' @export
vec_ptype2.double.csl_date <- vec_ptype2.csl_date.double

#' @method vec_cast.double csl_date
#' @export
vec_cast.double.csl_date <- function(x, to, ...) {
vapply(x, function(x) if(is.null(x)) NA_real_ else x[[1]][[1]], numeric(1L))
}
#' @method vec_cast.character csl_date
#' @export
vec_cast.character.csl_date <- function(x, to, ...) {
format(x)
Expand Down
4 changes: 4 additions & 0 deletions R/vitae-package.R
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#' @keywords internal
"_PACKAGE"


#' @import vctrs
NULL

0 comments on commit 3155367

Please sign in to comment.