Learn R Programming

vcr (version 0.2.6)

Hooks: Hooks class

Description

Hooks class

Arguments

hooks

List of hooks

hook_type, x

(character) Hook name

args

Args passed when invoking a hook

plac

Placement, one of "start" or "end"

fun

A function

prepend

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

Details

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

invoke_hook(hook_type, args)

Invoke a hook, i.e., call a hook.

clear_hooks()

Remove all hooks.

define_hook(hook_type, fun, prepend = FALSE)

Define a hook.

Private Methods

make_hook(x, plac, fun)

Make a hook.

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 DataLab