line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Application::Muto::MethodAttributes;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This module code has been taken almost entirely from the module
|
4
|
|
|
|
|
|
|
# CGI::Application::Plugin::ActionDispatch::Attributes by Jason Yates,
|
5
|
|
|
|
|
|
|
# jaywhy@gmail.com
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
931
|
use attributes;
|
|
1
|
|
|
|
|
1364
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
60
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
415
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.1';
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my @attributes;
|
13
|
|
|
|
|
|
|
my %attr_handlers;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $init = 1;
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# MODIFY_CODE_ATTRIBUTES needs to be in the inheritance tree.
|
18
|
|
|
|
|
|
|
push @CGI::Application::Muto::ISA, 'CGI::Application::Muto::MethodAttributes'
|
19
|
|
|
|
|
|
|
unless grep /^CGI::Application::Muto::MethodAttributes$/, @CGI::Application::Muto::ISA;
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub MODIFY_CODE_ATTRIBUTES {
|
23
|
0
|
|
|
0
|
|
|
my($class, $code, @attrs) = @_;
|
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
foreach (@attrs) {
|
26
|
|
|
|
|
|
|
# Parse the attribute string ex: Regex('^/foo/bar/(\d+)/').
|
27
|
0
|
|
|
|
|
|
my($method, $params) = /^([a-z_]\w*)(?:[(](.*)[)])?$/is;
|
28
|
0
|
0
|
|
|
|
|
$params =~ s/(^'|'$)//g if defined $params;
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Attribute definition.
|
31
|
0
|
0
|
|
|
|
|
if($method eq 'ATTR') {
|
32
|
0
|
|
|
|
|
|
$attr_handlers{$code} = $params
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
# Is a custom attribute.
|
35
|
|
|
|
|
|
|
else {
|
36
|
0
|
|
|
|
|
|
my $handler = $class->can($method);
|
37
|
0
|
0
|
|
|
|
|
next unless $handler;
|
38
|
0
|
|
|
|
|
|
push(@attributes, [ $class, $method, $code, $params ] );
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return ();
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub init {
|
46
|
0
|
0
|
|
0
|
0
|
|
return unless $init; # Initialize only once
|
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
foreach my $attr (@attributes) {
|
49
|
0
|
|
|
|
|
|
my $class = $attr->[0];
|
50
|
0
|
|
|
|
|
|
my $method = $attr->[1];
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# calls: class->method( code, method, params );
|
53
|
0
|
|
|
|
|
|
$class->$method( $attr->[2], $attr->[1], $attr->[3]);
|
54
|
|
|
|
|
|
|
}
|
55
|
0
|
|
|
|
|
|
$init = 0;
|
56
|
|
|
|
|
|
|
}
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1;
|
60
|
|
|
|
|
|
|
|