R/template_constructor.R

Defines functions template_constructor

# eml_creator <- template_constructor("creator")
template_constructor <- function(object) {
  args <- emld::template(object)
  names(args) <- gsub("^(\\w+:)*(\\w+)", "\\2", names(args))
  f <- paste0(
    "function(",
    paste(names(args), "=", args, collapse = ", "),
    "){ list(",
    paste(names(args), "=", names(args), collapse = ","),
    ")}"
  )
  eval(parse(text = f))
}


# who <- readLines(system.file("extdata/complexTypes.txt", package="EML"))
# names(who) <- who
# construct <- lapply(who, template_constructor)

#' eml
#'
#' @docType data
#' @keywords datasets
#' @name eml
#' @format A list with constructor functions
NULL

Try the EML package in your browser

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

EML documentation built on April 29, 2022, 1:06 a.m.