ActionExporter

 view release on metacpan or  search on metacpan

ActionExporter.pm  view on Meta::CPAN


ActionExporter - Extends Exporter with the export_action() function, for use with the GCT::XSP::ActionTaglib module.

=head1 SYNOPSIS

    require ActionExporter;
    our @ISA = ("ActionExporter");

    ActionExporter::export_action("foo");

    sub foo_start{ #... }
    sub foo_end{ #... }

=head1 DESCRIPTION

Extends Exporter with the export_action() function. Calling ActionExporter::export_action("foo") exports the two subs 'foo_start' and 'foo_end' under a export tag 'foo'. This is usefull for creating an action Library as follows:

    package MyActionsLibrary;
    require ActionExporter;
    our @ISA = ("ActionExporter");

    ActionExporter::export_action("foo");
    sub foo_start{ return '';}
    sub foo_end{   return '';}

    ActionExporter::export_action("bar");
    sub bar_start{ return '';}
    sub bar_end{   return '';}

A taglib created using using ActionTaglib can then use the 'foo' actions by simply adding 'use MyActionLibrary qw(:foo);', for example:

    package MyTaglib;
    use GCT::XSP::ActionTaglib;
    @ISA = qw(use GCT::XSP::ActionTaglib;);
    our $tagactions;

    use MyActionLibrary qw(:foo);

ActionExporter.pm  view on Meta::CPAN

sub export_action{
    my ($caller,undef,undef)=caller; 
    my $action = shift;
    my ($ex_tags,$ex_ok);
    {
	no strict;
	$ex_tags = \%{"${caller}::EXPORT_TAGS"};
	$ex_ok = \@{"${caller}::EXPORT_OK"};
    }

    if ($caller->can("$action" . '_start')) {
	push @{ $ex_tags->{$action} }, ("$action" . '_start');
    }
    if ($caller->can("$action" . '_end')) {
	push @{ $ex_tags->{$action} }, ("$action" . '_end');
    }
    if( $ex_tags->{$action} ){
	push @$ex_ok,                     @{ $ex_tags->{$action} };
	push @{ $ex_tags->{allactions} }, @{ $ex_tags->{$action} };
    }
}

Changes  view on Meta::CPAN

Revision history for Perl extension ActionExporter.

0.01  Tue May 21 17:15:00 2003
	- original version; created
0.02  Tue May 21 23:45:00 2003
        - Better behaviour for actions that don't use either a _start sub or an _end sub.



( run in 0.428 second using v1.01-cache-2.11-cpan-0d8aa00de5b )