line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
ActionExporter - Extends Exporter with the export_action() function, for use with the GCT::XSP::ActionTaglib module. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require ActionExporter; |
8
|
|
|
|
|
|
|
our @ISA = ("ActionExporter"); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
ActionExporter::export_action("foo"); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub foo_start{ #... } |
13
|
|
|
|
|
|
|
sub foo_end{ #... } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
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: |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package MyActionsLibrary; |
20
|
|
|
|
|
|
|
require ActionExporter; |
21
|
|
|
|
|
|
|
our @ISA = ("ActionExporter"); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
ActionExporter::export_action("foo"); |
24
|
|
|
|
|
|
|
sub foo_start{ return '';} |
25
|
|
|
|
|
|
|
sub foo_end{ return '';} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
ActionExporter::export_action("bar"); |
28
|
|
|
|
|
|
|
sub bar_start{ return '';} |
29
|
|
|
|
|
|
|
sub bar_end{ return '';} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
A taglib created using using ActionTaglib can then use the 'foo' actions by simply adding 'use MyActionLibrary qw(:foo);', for example: |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
package MyTaglib; |
34
|
|
|
|
|
|
|
use GCT::XSP::ActionTaglib; |
35
|
|
|
|
|
|
|
@ISA = qw(use GCT::XSP::ActionTaglib;); |
36
|
|
|
|
|
|
|
our $tagactions; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use MyActionLibrary qw(:foo); |
39
|
|
|
|
|
|
|
$tagactions->{tag1}=[{ -action => 'foo' }]; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Actions exported using the export_action() command are also added to the 'allactions' export tag so a taglib could import all the actions from an action library with: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use MyActionLibrary qw(:allactions); |
44
|
|
|
|
|
|
|
$tagactions->{tag1}=[{ -action => 'foo' }]; |
45
|
|
|
|
|
|
|
$tagactions->{tag2}=[{ -action => 'bar' }]; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
1
|
|
13304
|
use 5.006; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
56
|
|
50
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
88
|
|
|
1
|
|
|
|
|
47
|
|
51
|
1
|
|
|
1
|
|
14
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
150
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
package ActionExporter; |
54
|
|
|
|
|
|
|
require Exporter; |
55
|
|
|
|
|
|
|
our @ISA = ("Exporter"); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
58
|
|
|
|
|
|
|
our $REVISION; $REVISION = '$Revision: 1.2 $'; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# variables changed in the caller by export_action |
61
|
|
|
|
|
|
|
# our @EXPORT_OK; |
62
|
|
|
|
|
|
|
# our %EXPORT_TAGS; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub export_action{ |
65
|
0
|
|
|
0
|
0
|
|
my ($caller,undef,undef)=caller; |
66
|
0
|
|
|
|
|
|
my $action = shift; |
67
|
0
|
|
|
|
|
|
my ($ex_tags,$ex_ok); |
68
|
|
|
|
|
|
|
{ |
69
|
1
|
|
|
1
|
|
5
|
no strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
474
|
|
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$ex_tags = \%{"${caller}::EXPORT_TAGS"}; |
|
0
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$ex_ok = \@{"${caller}::EXPORT_OK"}; |
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ($caller->can("$action" . '_start')) { |
75
|
0
|
|
|
|
|
|
push @{ $ex_tags->{$action} }, ("$action" . '_start'); |
|
0
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
0
|
0
|
|
|
|
|
if ($caller->can("$action" . '_end')) { |
78
|
0
|
|
|
|
|
|
push @{ $ex_tags->{$action} }, ("$action" . '_end'); |
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
0
|
0
|
|
|
|
|
if( $ex_tags->{$action} ){ |
81
|
0
|
|
|
|
|
|
push @$ex_ok, @{ $ex_tags->{$action} }; |
|
0
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
push @{ $ex_tags->{allactions} }, @{ $ex_tags->{$action} }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |