Information about the function being decorated

Description

Call this from inside a decorator to find out which function it is currently wrapping.

Usage

decorator_context()

Value

A list with name (the name the function is bound to, or “<anonymous>”), decorator (the decorator’s name, see decorator()) and fn (the function being wrapped).

Examples

library("adorn")

who <- decorator(function(f, ...) {
  message("calling ", decorator_context()$name)
  f(...)
})
hello <- who %@% function() "hi"
hello()
#> [1] "hi"