NAME

oEdtk::Ext - plug corporate extensions into the generic oEdtk without a registry

SYNOPSIS

use oEdtk::Ext qw(require_optional load_named_callable call_named_callable);

# (a) optional companion module, by its fixed name
if ( require_optional('oEUser::Schema') ) {
    my @tables = oEUser::Schema::extra_tables();
}

# (b) callable named in the configuration
my $code = load_named_callable( $cfg, 'EDTK_ACQUIT_API' );    # undef if absent
call_named_callable( $cfg, 'EDTK_ACQUIT_API', $docid, $date );

DESCRIPTION

Two extension points that let a deployment add corporate behaviour to the generic oEdtk without oEdtk depending on the companion distribution oEUser (decision D18):

  • require_optional loads a companion module with a fixed name (for example oEUser::Lib or oEUser::Schema) and returns 1 on success, 0 when it is not installed. A missing extension is a documented default, not an error.

  • load_named_callable resolves a Module::function name read from the configuration (for example EDTK_ACQUIT_API) and returns the coderef. The name is validated by a regular expression before any load. An absent or empty value returns undef (the caller then does nothing); a syntactically invalid name, or a valid name that cannot be resolved, is an explicit error. call_named_callable resolves and calls in one step.

The configuration file is trusted administration data: a name that passes the regular expression is required explicitly, and the loaded module is responsible for its own behaviour.

FUNCTIONS

require_optional

my $ok = require_optional($module);

Load a companion module by its fixed name; return 1 on success, 0 when it is not installed. A missing extension is a documented default, not an error.

load_named_callable

my $code = load_named_callable($cfg, $key);

Resolve the Module::function name read from $cfg under $key and return the coderef, or undef when the value is absent or empty. A syntactically invalid name, or a valid name that cannot be resolved, is an error.

call_named_callable

call_named_callable($cfg, $key, @args);

Resolve the callable named by $key and call it with @args.

AUTHOR

The oEdtk team.