line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dispatch::Class; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
41406
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
84
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
127
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
14
|
use Scalar::Util qw(blessed); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
269
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
1148
|
use parent 'Exporter::Tiny'; |
|
2
|
|
|
|
|
658
|
|
|
2
|
|
|
|
|
11
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
12
|
|
|
|
|
|
|
class_case |
13
|
|
|
|
|
|
|
dispatch |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub class_case { |
17
|
2
|
|
|
2
|
1
|
41
|
my @prototable = @_; |
18
|
|
|
|
|
|
|
sub { |
19
|
16
|
|
|
16
|
|
54
|
my ($x) = @_; |
20
|
16
|
|
|
|
|
43
|
my $blessed = blessed $x; |
21
|
16
|
|
|
|
|
20
|
my $ref = ref $x; |
22
|
16
|
|
|
|
|
14
|
my $DOES; |
23
|
16
|
|
|
|
|
41
|
my @table = @prototable; |
24
|
16
|
|
|
|
|
42
|
while (my ($key, $value) = splice @table, 0, 2) { |
25
|
62
|
100
|
100
|
|
|
579
|
return $value if |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
26
|
|
|
|
|
|
|
!defined $key ? !defined $x : |
27
|
|
|
|
|
|
|
$key eq '*' ? 1 : |
28
|
|
|
|
|
|
|
$key eq ':str' ? !$ref : |
29
|
|
|
|
|
|
|
$key eq $ref ? 1 : |
30
|
|
|
|
|
|
|
$blessed && ($DOES ||= $x->can('DOES') || 'isa', $x->$DOES($key)) |
31
|
|
|
|
|
|
|
; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
() |
34
|
2
|
|
|
|
|
11
|
} |
35
|
2
|
|
|
|
|
11
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub dispatch { |
38
|
1
|
|
|
1
|
1
|
3
|
my $chk = &class_case; |
39
|
12
|
|
50
|
12
|
|
8052
|
sub { ($chk->($_[0]) || return)->($_[0]) } |
40
|
1
|
|
|
|
|
4
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
'ok' |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |