library(crudr) run <- FALSE root_dir <- paste(rep("../", 1), collapse = "") knitr::opts_chunk$set(comment = "#>", collapse = TRUE) knitr::opts_knit$set(root.dir = root_dir)
## crudr_uml <- ' ## @startuml ## ICrud *-- Crud: implements < ## Crud <|-- Crud.Settings: extends < ## ## class ICrud { ## +init() ## +has() ## +create() ## +read() ## +update() ## +delete() ## +reset() ## -stopIfInterface() ## } ## class Crud { ## +main: environment ## -initial_state: list ## -stopIfEmpty() ## -createMessage(), ## -cacheInitialState() ## } ## class Crud.Settings { ## +main: function ## -cacheInitialState() ## } ## @enduml ## ## knitr::opts_knit$set(root.dir = root_dir) ## uml_file <- crudr:::plantuml3( ## crudr_uml, 'Architecture', ## filename = "vignettes/uml", ## jarfile = "lib/plantuml.jar", ## normalize = TRUE ## ) ## print(uml_file) ## uml_file <- normalizePath(uml_file) ## print(uml_file) ## knitr::opts_knit$set(root.dir = getwd()) uml_file <- normalizePath("vignettes/uml.png")
inst <- Crud.Settings$new()
inst$init(a = 1, b = 2) inst$getMain() ## --> this is actually the return value of calling ## `settings::options_manager(a = 1, b = 2)` inst$getMain()()
inst$has("a") inst$has("b") inst$has("a", "b") inst$has("c") inst$has("a", "c")
inst$create(c = 3) inst$create(d = 4, f = 5) inst$read() try(inst$create(c = 30)) inst$read() ## --> c already existed with value = 3 inst$create(c = 30, strict = 1) try(inst$create(c = 30, strict = 2)) try(inst$create(c = 30, strict = 3)) inst$create(c = 30, overwrite = TRUE) inst$read() ## --> c overwritten
inst$read() inst$read("a") inst$read("a", "b") inst$read("a", "b", "x") try(inst$read("a", "b", "x", strict = 3))
inst$read("a") inst$update(a = 10) inst$read("a") inst$read("a", "b") inst$update(a = 1000, b = 2000) inst$read("a", "b") inst$update(x = 99) inst$read("x") inst$read("a", "x") inst$update(a = 1, x = 99) try(inst$update(a = 1, x = 99, strict = 3)) inst$read("a", "x")
inst$read() inst$delete("f") inst$delete("d", "c") inst$read() inst$delete("x") inst$read() inst$delete("b", "x") try(inst$delete("b", "x", strict = 3)) inst$read()
inst$reset() inst$read() inst$reset(type = "hard") inst$read()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.