expose: Expose module contents

Description Usage Arguments Details Examples

View source: R/expose.R

Description

Use expose to copy the exported member of a module to the calling environment. This is useful for a simple reexport of member functions and generally for object composition.

Usage

1
expose(module, ..., reInit = TRUE, where = parent.frame())

Arguments

module

(character | module) a module as file or folder name or a list representing a module.

...

(character, or unquoted expression) elements to be exposed. Defaults to all.

reInit

(logical) whether to re-initialize module. This is only relevant if a module has state which can be changed. This argument is passed to as.module.

where

(environment) typically the calling environment. Should only be relevant for testing.

Details

You call this function for its side effects. It is a variation of use where instead of returning a module as return value, the elements are copied to the calling environment.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
m1 <- module({
  foo <- function() "foo"
})
m2 <- module({
  bar <- function() "bar"
})
# Now we create a module with 'foo' and 'bar' as member functions.
m3 <- module({
  expose(m1)
  expose(m2)
})
m3$foo()
m3$bar()

modules documentation built on Feb. 7, 2021, 1:06 a.m.