make_methods: Make methods

Description Usage Arguments Value Examples

View source: R/make_methods.R

Description

Make methods

Usage

1
2
3
4
5
6
7
make_methods(
  r6,
  field = c("all", "public", "private", names(r6$public_fields),
    names(r6$private_fields)),
  method = c("both", "get", "set"),
  add_roxygen = TRUE
)

Arguments

r6

R6 class for which to create methods

field

Character, fields for which to create method. May be "all", "public", "private" or name of class field. Multiple values allowed.

method

Character, methods to create. One of "both", "get", "set"

add_roxygen

Logical, whether to add roxygen description of method

Value

Character containing generated methods to put into class definition

Examples

1
2
3
4
5
Example <- R6::R6Class("Example", list(public_field = NULL), list(private_field = NULL))
make_methods(Example)
make_methods(Example, "private", "get")
make_methods(Example, "private_field", c("get", "set"))
make_methods(Example, "public_field", c("both"))

r6methods documentation built on March 16, 2021, 9:06 a.m.