Skip to content

Commit

Permalink
Fixes to is* fns, as requested by @wch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Cotton committed Sep 20, 2016
1 parent 61d076d commit 9e1a18d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 46 deletions.
5 changes: 2 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ S3method(plot,R6)
S3method(print,R6)
S3method(print,R6ClassGenerator)
export(R6Class)
export(is.r6)
export(is.r6gen)
export(is.r6obj)
export(is.R6)
export(is.R6Class)
35 changes: 13 additions & 22 deletions R/is.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,28 @@
#' Checks for R6 class generators and R6 objects.
#' @param x Any variable.
#' @return A logical value.
#' \code{is.r6} returns \code{TRUE} when the input is an R6 class generator or
#' an R6 object, and \code{FALSE} otherwise.
#' \code{is.r6gen} returns \code{TRUE} when the input is an R6 class generator
#' and \code{FALSE} otherwise.
#' \code{is.r6obj} returns \code{TRUE} when the input is an R6 object and
#' \code{FALSE} otherwise.
#' \itemize{
#' \item{\code{is.R6Class} returns \code{TRUE} when the input is an R6 class
#' generator and \code{FALSE} otherwise.}
#' \item{\code{is.R6} returns \code{TRUE} when the input is an R6 object and
#' \code{FALSE} otherwise.}
#' }
#' @examples
#' class_generator <- R6::R6Class()
#' class_generator <- R6Class()
#' object <- class_generator$new()
#' is.r6(class_generator)
#' is.r6gen(class_generator)
#' is.r6obj(class_generator)
#' is.r6(object)
#' is.r6gen(object)
#' is.r6obj(object)
#' is.R6Class(class_generator)
#' is.R6(class_generator)
#' is.R6Class(object)
#' is.R6(object)
#' @export
is.r6 <- function(x)
{
is.r6obj(x) || is.r6gen(x)
}

#' @rdname is.r6
#' @export
is.r6obj <- function(x)
{
is.R6 <- function(x) {
inherits(x, "R6")
}

#' @rdname is.r6
#' @export
is.r6gen <- function(x)
{
is.R6Class <- function(x) {
inherits(x, "R6ClassGenerator")
}
37 changes: 16 additions & 21 deletions man/is.r6.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9e1a18d

Please sign in to comment.