Skip to content

Instantly share code, notes, and snippets.

@sdondley
Created June 24, 2022 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdondley/e45a9ad0a32467f1df8150b1df80c769 to your computer and use it in GitHub Desktop.
Save sdondley/e45a9ad0a32467f1df8150b1df80c769 to your computer and use it in GitHub Desktop.
trait_mod for automatically checking and modifying arguments to methods on the fly
multi sub trait_mod:<is>(Method $obj, Bool :$path-checked) {
$obj.wrap: -> $inv, $path, |c {
if $path.starts-with: $inv.root {
callsame;
} else {
callwith $inv, $inv.root ~ $path, |c;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment