File: onLoad.R

package info (click to toggle)
r-cran-vcr 0.6.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,360 kB
  • sloc: cpp: 15; sh: 13; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 861 bytes parent folder | download | duplicates (3)
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
vcr_c <- NULL # nocov start
VCRHooks <- NULL
request_matchers <- NULL
request_ignorer <- NULL
cassette_serializers <- NULL
cassette_persisters <- NULL
light_switch <- NULL
vcr_cassettes <- NULL

initialize_ivars <- function() {
  light_switch <<- new.env()
  light_switch$turned_off <<- FALSE
  light_switch$ignore_cassettes <<- FALSE
  vcr_c$cassettes <<- list()
  vcr_c$linked_context <<- NULL

  request_matchers <<- RequestMatcherRegistry$new()
  request_ignorer <<- RequestIgnorer$new()
  cassette_serializers <<- Serializers$new()
  cassette_persisters <<- Persisters$new()
}

.onLoad <- function(libname, pkgname){
  # initialize vcr config object
  vcr_c <<- VCRConfig$new()
  # initialize hooks
  VCRHooks <<- Hooks$new()
  # initialize bucket of cassettes in session
  vcr_cassettes <<- new.env()
  # lots of things
  initialize_ivars()
} # nocov end