retrieveFactory: Retrieve factory

Description Usage Details Value Author(s) Examples

View source: R/retrieveFactory.R

Description

As factory may be modified, this function allows you to make changes and to record them in your own specialized type factory, to match various needs and ease reuse.

Usage

1

Details

Retrieves a FunctionParameterTypeFactory from options variable named op_type_factory or provides a default type factory.

Value

An R object that is a FunctionParameterTypeFactory.

Author(s)

Fabien Gelineau <neonira@gmail.com>

Maintainer: Fabien Gelineau <neonira@gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
##---- typical case ----
ff <- retrieveFactory()
ff$addSuffix('wo', "wo class", function(o_) is(o_, "wo"))
ff$addSuffix('yo', "yo class", function(o_) is(o_, "yo"))
ff$addSuffix('zo', "zo class", function(o_) is(o_, "zo"))

options('op_type_factory' = ff)
fg <- retrieveFactory() # retrieves the factory pointed by R variable ff
fg$getRecordedTypes()[suffix %in% c('wo', 'yo', 'zo')] # right behavior !

# wrong behavior as retrieveFactory will provide the default factory and not yours!
options('op_type_factory' = ff)
fh <- retrieveFactory() # retrieves the default factory
fh$getRecordedTypes()[suffix %in% c('wo', 'yo', 'zo')]

neonira/wyz.code.offensiveProgramming documentation built on Feb. 20, 2020, 2:01 p.m.