Construct a module provider intended for defining modules that can be used as general purpose options and configuration containers.
options_provider(...)
... | Named arguments used as default options. If void, no default option is set. |
---|
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.
name %provides_options% options
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.
%<=%
, define
, make
,
%provides%
, %requires%
,
reset
, and touch
.
reset()#> [2018-12-02T17:14:07 CET] Resetting modulr state ... OK"foo/config" %provides% options_provider(upper = FALSE)#> [2018-12-02T17:14:07 CET] Defining 'foo/config' ... OK"foo" %requires% list(config = "foo/config") %provides% { function() casefold("foo", upper = config$upper) }#> [2018-12-02T17:14:07 CET] Defining 'foo' ... OKfoo %<=% "foo"#> [2018-12-02T17:14:07 CET] Making 'foo' ... #> [2018-12-02T17:14:07 CET] * Visiting and defining dependencies ... #> [2018-12-02T17:14:07 CET] * Constructing dependency graph ... OK #> [2018-12-02T17:14:07 CET] * Evaluating #1/1 (layer #1/1): 'foo/config' ... #> [2018-12-02T17:14:07 CET] DONE ('foo' in 0.05 secs)foo()#> [1] "foo"config %<=% "foo/config"#> [2018-12-02T17:14:07 CET] Making 'foo/config' ... #> [2018-12-02T17:14:07 CET] * Visiting and defining dependencies ... #> [2018-12-02T17:14:07 CET] * Constructing dependency graph ... OK #> [2018-12-02T17:14:07 CET] DONE ('foo/config' in 0.026 secs)config$upper <- TRUE foo()#> [1] "FOO""foo/config" %provides_options% list(upper = FALSE) foo %<=% "foo"#> [2018-12-02T17:14:07 CET] Making 'foo' ... #> [2018-12-02T17:14:07 CET] * Visiting and defining dependencies ... #> [2018-12-02T17:14:07 CET] * Constructing dependency graph ... OK #> [2018-12-02T17:14:07 CET] DONE ('foo' in 0.05 secs)foo()#> [1] "FOO"touch("foo/config")#> [2018-12-02T17:14:07 CET] Touching 'foo/config' ... OK"foo/config" %provides_options% list(upper = FALSE)#> [2018-12-02T17:14:07 CET] Re-defining 'foo/config' ... OKfoo %<=% "foo"#> [2018-12-02T17:14:07 CET] Making 'foo' ... #> [2018-12-02T17:14:07 CET] * Visiting and defining dependencies ... #> [2018-12-02T17:14:08 CET] * Constructing dependency graph ... OK #> [2018-12-02T17:14:08 CET] * Evaluating #1/1 (layer #1/1): 'foo/config' ... #> [2018-12-02T17:14:08 CET] DONE ('foo' in 0.053 secs)foo()#> [1] "foo"