package Maypole::Application;

use strict;
use warnings;

our @ISA;

sub import {
    my ( $self, @plugins ) = @_;
    my $caller = caller(0);
    no strict 'refs';
    push @{"${caller}::ISA"}, $self;
    "Maypole::$_"->require && unshift @ISA, "Maypole::$_" foreach (@plugins);
}

if ( $ENV{MOD_PERL} ) {
    require Apache::MVC;
    push @ISA, qw(Apache::MVC);
}
else {
    require CGI::Maypole;
    push @ISA, qw(CGI::Maypole);
}

1;

=head1 NAME

Maypole::Application - Maypole Universal Frontend

=head1 SYNOPSIS

    use Maypole::Application;

=head1 DESCRIPTION

This is a universal frontend for mod_perl1, mod_perl2 and CGI.

You can omit the Maypole:: prefix from plugins.
So Maypole::Config::YAML becomes Config::YAML.

    use Maypole::Application qw(Config::YAML);

=head1 AUTHOR

Sebastian Riedel, C<sri@oook.de>
Idea by Marcus Ramberg, C<marcus@thefeed.no>

=head1 LICENSE

You may distribute this code under the same terms as Perl itself.
