options_provider: Module Options Provider

Description Usage Arguments Value Syntactic Sugars Warning See Also Examples

View source: R/special.R

Description

Construct a module provider intended for defining modules that can be used as general purpose options and configuration containers.

Usage

1

Arguments

...

Named arguments used as default options. If void, no default option is set.

Value

A module provider which exposes an R environment. The default options arguments, if any, are used to assign the values to their corresponding names in the returned environment.

Syntactic Sugars

1
name %provides_options% options

Warning

It is considered a very bad practice to define, touch, undefine, load, make, reset, or perform any other operation from within a module definition that may alterate the internal state of modulr.

See Also

%<=%, define, make, %provides%, %requires%, reset, and touch.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
reset()

"foo/config" %provides% options_provider(upper = FALSE)

"foo" %requires% list(config = "foo/config") %provides% {
  function() casefold("foo", upper = config$upper)
}

foo %<=% "foo"
foo()

config %<=% "foo/config"
config$upper <- TRUE
foo()

"foo/config" %provides_options% list(upper = FALSE)
foo %<=% "foo"
foo()

touch("foo/config")
"foo/config" %provides_options% list(upper = FALSE)
foo %<=% "foo"
foo()

openscienceunil/modulr documentation built on May 3, 2019, 5:49 p.m.