Introduction
The describe()
method embeds hook action code attributes in your hook action code. This provides a programmatic means for the action code to express the developer's intended use of the hook.
Basic usage
To use the describe()
method, create a describe
subroutine that returns the appropriate category, event, stage, and other attributes for themanage_hooks
utility.
For more information, read our The manage_hooks Utility and Hook Action Code documentation.
The describe()
method in Perl modules
In Perl modules, the describe()
method must return a Perl array reference, which must contain one or more hash references.
- Each hash reference relates to one hookable action and creates a single entry for the Standardized Hooks database.
- The hash reference must, at minimum, contain the
category
,event
,stage
,exectype
, andhook
descriptors.
The describe()
method in scripts
Important:
Scripts must include argument evaluation in the hook action code in order to use the describe()
method. When you register hooks with script hook action code, the manage_hooks
utility calls the script with the --describe
argument.
In scripts, the describe()
method must return a JSON-encoded string. When you decode the string, the JSON structure must be an array that contains one or more hashes, or associative arrays.
- Each hash reference relates to one hookable action and creates a single entry for the Standardized Hooks database.
- The hash reference must, at minimum, contain the
category
,event
,stage
,exectype
, andhook
descriptors.
Make certain that the hook
descriptor uses the correct method to invoke the script in order to perform the hookable action.
- If the script is monolithic, and performs internal logic based on the context, provide the script's absolute path and filename.
- If the script can parse input arguments via a shell argument array (for example,
$argv
or@argv
), it should specify the absolute path and filename and the argument to switch to the proper code block.