R/ensure_that.R

Defines functions ensure_that

Documented in ensure_that

#' @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 30, 2017, 3:32 a.m.