NAME
MIME::Expander::Plugin - Abstract class for plugin of MIME::Expander
SYNOPSIS
# An implement class
package MIME::Expander::Plugin::MyExpander;
use parent qw(MIME::Expander::Plugin);
# This plugin has to be implemented class data 'ACCEPT_TYPES'
# to negotiate for acceptable type
__PACKAGE__->mk_classdata('ACCEPT_TYPES' => [qw(
type/sub-type
)]);
# And expand() for determine type
sub expand {
my $self = shift;
my $part = shift;
my $callback = shift;
my $count = 0;
my $contents = $part->body;
while( my $media = your_expand_function( $contents ) ){
my $data = $media->{data};
my $filename = $media->{name};
$callback->( \ $contents, {
filename => $filename, # optional, sometimes it is undef
});
++$count;
}
# number of expanded contents
return $count;
}
DESCRIPTION
MIME::Expander::Plugin is an abstract class for plugin of MIME::Expander.
Each plugins extended this class have to expand the contents of ACCEPT_TYPES and passes each to the callback.