vcr (version 0.5.4)

Hooks: Hooks class

Description

Helps define new hooks, hold hooks, and accessors to get and use hooks.

Arguments

Public fields

hooks

intenal use

Methods

Public methods

Method invoke_hook()

invoke a hook

Usage

Hooks$invoke_hook(hook_type, args)

Arguments

hook_type

(character) Hook name

args

(named list) Args passed when invoking a hook

Returns

executes hook

Method clear_hooks()

clear all hooks

Usage

Hooks$clear_hooks()

Returns

no return

Method define_hook()

define a hook

Usage

Hooks$define_hook(hook_type, fun, prepend = FALSE)

Arguments

hook_type

(character) Hook name

fun

A function

prepend

(logical) Whether to prepend or add to the end of the string. Default: FALSE

Returns

no return; defines hook internally

Method clone()

The objects of this class are cloneable with this method.

Usage

Hooks$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

Private Methods

make_hook(x, plac, fun)

Make a hook. - x (character) Hook name - plac Placement, one of "start" or "end" - fun a function/callback

Examples

Run this code
# NOT RUN {
(x <- Hooks$new())
x$hooks
x$define_hook(hook_type = "foo", fun = function(x) x ^ 2)
x$hooks$foo(4)
x$clear_hooks()
x$hooks
# }

Run the code above in your browser using DataCamp Workspace