vcr (version 0.5.4)

YAML: The YAML serializer

Description

class with methods for serializing via the yaml package

Arguments

Public fields

file_extension

(character) A file extension

path

(character) full path to the yaml file

string

(character) path string

Methods

Public methods

Method new()

Create a new YAML object

Usage

YAML$new(file_extension = ".yml", path = NULL, string = NULL)

Arguments

file_extension

(character) A file extension

path

(character) path to the cassette, excluding the cassette directory and the file extension. only use if not passing a string

string

(character) path string. only use if not passing a path

Returns

A new YAML object

Method serialize()

Serializes the given hash using internal fxn write_yaml

Usage

YAML$serialize(x, path, bytes)

Arguments

x

(list) the object to serialize

path

(character) the file path

bytes

(logical) whether to preserve exact body bytes or not

Returns

(character) the YAML string to write to disk

Method deserialize_string()

Deserializes the given string using yaml::yaml.load

Usage

YAML$deserialize_string(string = NULL)

Arguments

string

(character) the YAML string

Returns

(list) the deserialized object, an R list

Method deserialize_path()

Deserializes the given string using yaml::yaml.load_file

Usage

YAML$deserialize_path()

Returns

(list) the deserialized object, an R list

Method clone()

The objects of this class are cloneable with this method.

Usage

YAML$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

Run this code
# NOT RUN {
(yy <- YAML$new(path = "stuff2"))
fun <- yy$serialize()
fun(list(http_interactions = list(response = list(body = "bar"))),
  path = yy$path, bytes = FALSE)
yy$deserialize_path()
yy$deserialize_string(string = "- hey\n- hi\n- hello")
yy$deserialize_string(string = "- foo\n- bar\n- 3.14")
# }

Run the code above in your browser using DataLab