Inject a runtime patch into a locked package namespace

inject_patch(pkg, patch_list, lock = TRUE)

Arguments

pkg

A package name as a string.

patch_list

A named list of functions to overwrite in the package namespace.

lock

Whether to re-lock bindings after patching.

Value

Invisibly TRUE on success.

Examples

# Show baseline behavior with broken function
baseline <- dummy_parent_func("test")
print(baseline)
#> [1] "Parent output -> HOTFIXED! Input: test"

# Inject a patched version of the child function
inject_patch(
  pkg = "hotpatchR",
  patch_list = list(dummy_child_func = function(x) {
    paste("I am the FIXED child! Input:", x)
  })
)

# Call the parent function again - it now uses the patched child
patched_result <- dummy_parent_func("test")
print(patched_result)
#> [1] "Parent output -> I am the FIXED child! Input: test"