SYNOPSIS

    use Mail::Milter::ContextWrapper;

my $oldctx = ($ctx from callback);

# in the connect_callback $oldctx->setpriv(new Mail::Milter::ContextWrapper($ctx, { methodname => \&methodimpl[, ...] }));

# in all callbacks my $newctx = $ctx->getpriv();

# in the close_callback $oldctx->setpriv(undef);

DESCRIPTION

Mail::Milter::ContextWrapper wraps the milter context with replacement methods defined by the caller. This can be used to intercept context object actions and manipulate them from within a Mail::Milter::Wrapper.

Because the wrappering must occur on every callback, this implementation suggests embedding the wrapper inside the private data of the milter itself. This works with existing milters by providing separate \*(L"setpriv\*(R" and \*(L"getpriv\*(R" methods within the wrapper that do not propagate up to the embedded context object.

METHODS

new(\s-1CTX\s0, { \s-1NAME\s0 => \&SUB[, ...] })

Creates a Mail::Milter::ContextWrapper object. This should be called from the \*(L"connect\*(R" callback and passed back to \*(C`setpriv()\*(C'. NAMEs are names of methods to override within the wrapper. These methods will be called with the wrapper as first argument (like a normal object method).

getpriv()

Returns a private data item set by \*(C`setpriv()\*(C'. See Sendmail::Milter for more information. This implementation stores the datum in the wrapper, thus allowing the parent context to store a reference to the wrapper itself. This method cannot be overridden by the user.

get_ctx()

Returns the parent context object stored within this wrapper. Typically used by method overrides to defer back to the real method. This method cannot be overridden by the user.

get_key(\s-1NAME\s0)

Get a keyed data item separate from the \*(C`getpriv\*(C' private data. This provides out-of-band data storage that need not clobber the single \*(L"priv\*(R" data item used by most milters.

getpriv()

Sets a private data item to be returned by \*(C`getpriv()\*(C'. See Sendmail::Milter for more information. This implementation stores the datum in the wrapper, thus allowing the parent context to store a reference to the wrapper itself. This method cannot be overridden by the user.

set_key(\s-1NAME\s0, \s-1VALUE\s0)
set_key(\s-1NAME\s0 => \s-1VALUE\s0)

Set a keyed data item separate from the \*(C`getpriv\*(C' private data. This provides out-of-band data storage that need not clobber the single \*(L"priv\*(R" data item used by most milters.

AUTHOR

RELATED TO Mail::Milter::ContextWrapper…

Mail::Milter, Sendmail::Milter