R/construct.R

Defines functions deconstruct construct

Documented in construct deconstruct

#' @title Construct/deconstruct between objects and data frames
#'
#' @description
#' This function is designed to translate between data frame structures from
#' flat files or databases into the objects.
#'
#' Outside of a full ORM solution, this is best for just mapping S3, S4, and
#' R6 classes to databases with the goal of recreating them in some other
#' session.
#'
#' @param data (tbl) data frame object where each row is object data
#' @param objs (lst) list of objects conforming to that the class `defn`.
#' @param defn (opt) class definition
#'   * character - reference to an S4 class, function, or R6 class generator
#'   * S4 class  - S4 objects are expected
#'   * R6 class  - R6 objects are expected
#'   * function  - functions that generate S3 classes are expected
#' @param ...  (arg) method-specific arguments
#'
#' @family Object-Tibble Mapping
#' @export
construct <- function(data, defn, ...) {

  UseMethod("construct", defn)

}

#' @rdname construct
#' @export
deconstruct <- function(objs, defn, ...) {

  UseMethod("deconstruct", defn)

}
tjpalanca/dbtools documentation built on Oct. 7, 2021, 6:43 a.m.