line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Application::Plugin::ActionDispatch::Attributes; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
8041
|
use attributes; |
|
7
|
|
|
|
|
12087
|
|
|
7
|
|
|
|
|
44
|
|
4
|
7
|
|
|
7
|
|
483
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
281
|
|
5
|
7
|
|
|
7
|
|
40
|
use Data::Dumper; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
3099
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my @attributes; |
10
|
|
|
|
|
|
|
my %attr_handlers; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my %inited; # Allow multiple CGI::Applications to be inited separately in mod_perl enivironment |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# MODIFY_CODE_ATTRIBUTES needs to be in the inheritance tree. |
15
|
|
|
|
|
|
|
push @CGI::Application::ISA, 'CGI::Application::Plugin::ActionDispatch::Attributes' |
16
|
|
|
|
|
|
|
unless grep /^CGI::Application::Plugin::ActionDispatch::Attributes$/, @CGI::Application::ISA; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub MODIFY_CODE_ATTRIBUTES { |
19
|
55
|
|
|
55
|
|
4000
|
my($class, $code, @attrs) = @_; |
20
|
|
|
|
|
|
|
|
21
|
55
|
|
|
|
|
94
|
foreach (@attrs) { |
22
|
|
|
|
|
|
|
# Parse the attribute string ex: Regex('^/foo/bar/(\d+)/'). |
23
|
55
|
|
|
|
|
385
|
my($method, $params) = /^(.*?)(?:\(\s*(.+?)\s*\))?$/; |
24
|
|
|
|
|
|
|
|
25
|
55
|
100
|
|
|
|
135
|
if (defined $params) { |
26
|
13
|
100
|
|
|
|
88
|
($params =~ s/^'(.*)'$/$1/) || ($params =~ s/^"(.*)"/$1/) |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Attribute definition. |
30
|
55
|
100
|
|
|
|
121
|
if($method eq 'ATTR') { |
31
|
35
|
|
|
|
|
147
|
$attr_handlers{$code} = $params |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
# Is a custom attribute. |
34
|
|
|
|
|
|
|
else { |
35
|
20
|
|
|
|
|
152
|
my $handler = $class->can($method); |
36
|
20
|
50
|
|
|
|
57
|
next unless $handler; |
37
|
20
|
|
|
|
|
79
|
push(@attributes, [ $class, $method, $code, $params ] ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
55
|
|
|
|
|
166
|
return (); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub init { |
45
|
21
|
|
|
21
|
0
|
43
|
my $class; |
46
|
21
|
|
|
|
|
48
|
foreach my $attr (@attributes) { |
47
|
94
|
|
|
|
|
184
|
$class = $attr->[0]; |
48
|
94
|
100
|
|
|
|
331
|
next if( exists $inited{$class}); |
49
|
20
|
|
|
|
|
39
|
my $method = $attr->[1]; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# calls: class->method( code, method, params ); |
52
|
20
|
|
|
|
|
129
|
$class->$method( $attr->[2], $attr->[1], $attr->[3]); |
53
|
|
|
|
|
|
|
} |
54
|
21
|
|
|
|
|
510
|
$inited{$class}++; # Mark our caller class inited now, so that it can be skipped on next run |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
__END__ |