R/ensure_that.R

#' @rdname ensures_that
#' @export
ensure_that <- function(., ..., fail_with = function(e) stop(e), err_desc = "")
{
  env  <- new.env(parent = parent.frame())
  env[["ensures_that"]] <- ensures_that

  args <- c(eval(substitute(alist(...))),
            fail_with = fail_with, err_desc  = err_desc)

  cl <- as.call(c(quote(ensures_that), args))

  ensure_  <- eval(cl, env, env)

  ensure_(.)
}

#' @rdname ensures_that
#' @export
ensure <- ensure_that

Try the ensurer package in your browser

Any scripts or data that you put into this service are public.

ensurer documentation built on May 2, 2019, 12:35 p.m.