Skip to contents

as_string_replacements() turns an existing object into a string_replacements. This is in contrast with class_string_replacements(), which builds a string_replacements from individual properties.

Usage

as_string_replacements(x, ...)

Arguments

x

The object to coerce. Must be empty or be a list of named lists, each with names "enum", "default", or "description", or names that can be coerced to those names via snakecase::to_snake_case(). Additional names are ignored.

...

These dots are for future extensions and must be empty.

Value

A string_replacements as returned by class_string_replacements().

Examples

as_string_replacements()
#> <rapid::string_replacements>
#>  @ name       : chr(0) 
#>  @ default    : chr(0) 
#>  @ enum       : list()
#>  @ description: chr(0) 
as_string_replacements(
  list(
    username = c(
      default = "demo",
      description = "Name of the user."
    ),
    port = list(
      default = "8443",
      enum = c("8443", "443")
    )
  )
)
#> <rapid::string_replacements>
#>  @ name       : chr [1:2] "username" "port"
#>  @ default    : chr [1:2] "demo" "8443"
#>  @ enum       :List of 2
#>  .. $ : NULL
#>  .. $ : chr [1:2] "8443" "443"
#>  @ description: chr [1:2] "Name of the user." NA