buildExpressionFromYaml-ObjectReferenceYamlParsed.S3-method: Build Expression Based on YAML Markup...

Description Usage Arguments Value Author(s) References See Also Examples

Description

See generic: buildExpressionFromYaml

Usage

1
2
3
## S4 method for signature 'ObjectReferenceYamlParsed.S3'
buildExpressionFromYaml(yaml,
  where = parent.frame(), ...)

Arguments

yaml

ObjectReferenceYamlParsed.S3.

where

environment. Environment in which to assign the function in the src field of class ObjectReferenceYaml.S3. Only relevant in case the YAML has been provided via comments instead of an inline string as this involves some additional transformation steps.

...

Further arguments to be passed to subsequent functions/methods.

Value

ObjectReferenceYamlProcessed.S3. Processed YAML markup.

Author(s)

Janko Thyson janko.thyson@rappster.de

References

http://github.com/Rappster/yamlr

See Also

buildExpressionFromYaml

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
## Not run: 

## Get //  
yaml <- getYaml(
  from = function() {
  "object-ref: {id: x_1, where: .GlobalEnv, as: ref_1}"
  },
  ctx = YamlContext.ObjectReference.S3()
)

## Parse //
yaml <- parseYaml(yaml = yaml)

## Build //
yaml <- buildExpressionFromYaml(yaml = yaml)

## Two ways of accessing expressions //
## 1) Via 'parsed':
ls(yaml$parsed$x_1$expr)
yaml$parsed$x_1$expr$exists
yaml$parsed$x_1$expr$validate
yaml$parsed$x_1$expr$get_assign

## 2) Via 'expr':
ls(yaml$expr$x_1)
yaml$expr$x_1$exists
yaml$expr$x_1$validate
yaml$expr$x_1$get_assign

## NOTE
## The environment in `expr${id}` corresponds to the environment 
## in `parsed${id}$expr. So expressions are not actually stored redundantly
## as environments implement a "pass-by-referenc" instead of the otherwise
## typical "pass-by-value" paradigm. 
## Environment `expr` simply exists as a shorthand for accessing expressions

## Example of expression execution //
## Validity checks:
suppressWarnings(rm(x_1))
eval(yaml$parsed$x_1$expr$exists)
eval(yaml$parsed$x_1$expr$validate)
x_1 <- 10
eval(yaml$parsed$x_1$expr$exists)
eval(yaml$parsed$x_1$expr$validate)

## The line that contained the YAML markup in 'from' above will be substituted
## by this expression 
eval(yaml$parsed$x_1$expr$get_assign)
ref_1


## End(Not run)

rappster/yamlr documentation built on May 27, 2019, 2:02 a.m.