| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Exporter::Declare::Export; |
|
2
|
11
|
|
|
11
|
|
842
|
use strict; |
|
|
11
|
|
|
|
|
18
|
|
|
|
11
|
|
|
|
|
362
|
|
|
3
|
11
|
|
|
11
|
|
72
|
use warnings; |
|
|
11
|
|
|
|
|
22
|
|
|
|
11
|
|
|
|
|
302
|
|
|
4
|
11
|
|
|
11
|
|
58
|
use Carp qw/croak carp/; |
|
|
11
|
|
|
|
|
20
|
|
|
|
11
|
|
|
|
|
665
|
|
|
5
|
11
|
|
|
11
|
|
72
|
use Scalar::Util qw/reftype/; |
|
|
11
|
|
|
|
|
17
|
|
|
|
11
|
|
|
|
|
4665
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our %OBJECT_DATA; |
|
8
|
|
|
|
|
|
|
|
|
9
|
128
|
|
|
128
|
1
|
268
|
sub required_specs {qw/ exported_by /} |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
128
|
|
|
128
|
1
|
6588
|
my $class = shift; |
|
13
|
128
|
|
|
|
|
419
|
my ( $item, %specs ) = @_; |
|
14
|
128
|
|
|
|
|
328
|
my $self = bless( $item, $class ); |
|
15
|
|
|
|
|
|
|
|
|
16
|
128
|
|
|
|
|
355
|
for my $prop ( $self->required_specs ) { |
|
17
|
134
|
100
|
|
|
|
519
|
croak "You must specify $prop when calling $class\->new()" |
|
18
|
|
|
|
|
|
|
unless $specs{$prop}; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
126
|
|
|
|
|
11950
|
$OBJECT_DATA{$self} = \%specs; |
|
22
|
|
|
|
|
|
|
|
|
23
|
126
|
|
|
|
|
527
|
return $self; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _data { |
|
27
|
32
|
|
|
32
|
|
42
|
my $self = shift; |
|
28
|
32
|
50
|
|
|
|
66
|
($OBJECT_DATA{$self}) = @_ if @_; |
|
29
|
32
|
|
|
|
|
171
|
$OBJECT_DATA{$self}; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub exported_by { |
|
33
|
10
|
|
|
10
|
1
|
648
|
shift->_data->{ exported_by }; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub inject { |
|
37
|
86
|
|
|
86
|
1
|
132
|
my $self = shift; |
|
38
|
86
|
|
|
|
|
213
|
my ( $class, $name, @args ) = @_; |
|
39
|
|
|
|
|
|
|
|
|
40
|
86
|
100
|
|
|
|
238
|
carp( |
|
41
|
|
|
|
|
|
|
"Ignoring arguments importing (" |
|
42
|
|
|
|
|
|
|
. reftype($self) |
|
43
|
|
|
|
|
|
|
. ")$name into $class: " |
|
44
|
|
|
|
|
|
|
. join( ', ', @args ) |
|
45
|
|
|
|
|
|
|
) if (@args); |
|
46
|
|
|
|
|
|
|
|
|
47
|
86
|
50
|
33
|
|
|
1140
|
croak "You must provide a class and name to inject()" |
|
48
|
|
|
|
|
|
|
unless $class && $name; |
|
49
|
11
|
|
|
11
|
|
76
|
no strict 'refs'; |
|
|
11
|
|
|
|
|
19
|
|
|
|
11
|
|
|
|
|
330
|
|
|
50
|
11
|
|
|
11
|
|
59
|
no warnings 'once'; |
|
|
11
|
|
|
|
|
17
|
|
|
|
11
|
|
|
|
|
1378
|
|
|
51
|
86
|
|
|
|
|
95
|
*{"$class\::$name"} = $self; |
|
|
86
|
|
|
|
|
623
|
|
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub DESTROY { |
|
55
|
5
|
|
|
5
|
|
6571
|
my $self = shift; |
|
56
|
5
|
|
|
|
|
35
|
delete $OBJECT_DATA{$self}; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 NAME |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Exporter::Declare::Export - Base class for all export objects. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
All exports are refs, and all are blessed. This class tracks some per-export |
|
68
|
|
|
|
|
|
|
information via an inside-out objects system. All things an export may need to |
|
69
|
|
|
|
|
|
|
do, such as inject itself into a package are handled here. This allows some |
|
70
|
|
|
|
|
|
|
complicated, or ugly logic to be abstracted out of the exporter and metadata |
|
71
|
|
|
|
|
|
|
classes. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=over |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item $class->new( $ref, exported_by => $package, %data ) |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Create a new export from $ref. You must specify the name of the class doing the |
|
80
|
|
|
|
|
|
|
exporting. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item $export->inject( $package, $name, @args ) |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This will inject the export into $package under $name. @args are ignored in |
|
85
|
|
|
|
|
|
|
most cases. See L<Exporter::Declare::Export::Generator> for an example where |
|
86
|
|
|
|
|
|
|
they are used. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item $package = $export->exported_by() |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns the name of the package from which this export was originally exported. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item @params = $export->required_specs() |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Documented for subclassing purposes. This should always return a list of |
|
95
|
|
|
|
|
|
|
required parameters at construction time. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item $export->DESTROY() |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Documented for subclassing purposes. This takes care of cleanup related to |
|
100
|
|
|
|
|
|
|
storing data in an inside-out objects system. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=back |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHORS |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Chad Granum L<exodist7@gmail.com> |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Copyright (C) 2010 Chad Granum |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Exporter-Declare is free software; Standard perl licence. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Exporter-Declare is distributed in the hope that it will be useful, but |
|
115
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
116
|
|
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. |