Learn R Programming

futile.paradigm (version 1.0.2)

crud: API for CRUD-like operations

Description

Provides a high-level API for abstracting CRUD operations for arbitrary objects. Currently only create is provided, as this is essential for type management within futile.paradigm. Others will be added as necessary.

Usage

create(x, ...)
create.default(type, ...)

Arguments

x
An arbitrary object
type
A symbol or character that represents a type
...
Additional arguments to pass to dispatched functions

Value

  • 'create' returns an object of the requested type.

Details

Adding to 'create' requires a minimal function definition as the harness is provided in the package. Typically a list is returned and the function defines any defaults needed. This is similar to the S4 style but is simpler and not a requirement for using the rest of futile.paradigm.

Note that in general the futile.paradigm avoids strings where syntax is explicit enough that this is possible. By convention types are PascalCased, which makes identifying a type even clearer.

Examples

Run this code
create.Car <- function(x, wheels=4, doors=2) list(wheels=wheels, doors=doors)
my.car <- create(Car, doors=4)

isa(Car, my.car)

Run the code above in your browser using DataLab