parse_fields: Parse out field class names and prototypes.

Description Usage Arguments Value

Description

Parse out field class names and prototypes.

A field definition (field_value) can be either a character or a binding function (see the fields parameter).

Usage

1
2
3
parse_fields(fields, where)

parse_field(field_name, field_value, where)

Arguments

fields

list. A named list of characters or functions. If character, this represents the class name of the field (for example, "data.frame"). If a function, an active binding that will be used for the field prototype. For example, if we have a field radius and a field diameter, we could set the default value of radius (its prototype) to function() 2 * radius, which wil be evaluated within the context of the reference class environment.

where

environment. Where to look for class definitions.

field_name

character. The name of the field. (This is primarily used for error messages when the field_value does not validate all conditions.)

field_value

character or function. See fields.

Value

a list with three keys, names, classes and prototypes of class names and prototypes, respectively. Prototypes are just the default values of the respective fields.

a list with two values, class name and prototype value.


robertzk/refclass documentation built on May 27, 2019, 10:36 a.m.