The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MIME::Expander::Plugin - Abstract class for plugin of MIME::Expander

SYNOPSIS

# An implemented 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
    type/x-sub-type
    )]);

# And expand() for determine type
sub expand {
    my $self        = shift;
    my $contents    = shift;
    my $callback    = shift;
    my $count       = 0;

    while( my $media = expand_contents( $contents ) ){
        my $data     = $media->{data};
        my $filename = $media->{name};
        $callback->( \ $contents, {
            filename => $filename, # optional
            });
        ++$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.

SEE ALSO

MIME::Expander

Class::Data::Inheritable