line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tropo::WebAPI::Base; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Base class for Web-API part of Tropo API |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1446
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
76
|
|
6
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use Moo; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
27
|
|
9
|
2
|
|
|
2
|
|
590
|
use Types::Standard qw(HashRef); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
13
|
|
10
|
2
|
|
|
2
|
|
2696
|
use Class::Method::Modifiers qw(install_modifier); |
|
2
|
|
|
|
|
3579
|
|
|
2
|
|
|
|
|
670
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has attr => ( |
13
|
|
|
|
|
|
|
is => 'rw', |
14
|
|
|
|
|
|
|
isa => HashRef, |
15
|
|
|
|
|
|
|
default => sub { {} }, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub register { |
19
|
6
|
|
|
6
|
0
|
17
|
my $class = caller; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
install_modifier( $class, 'around', 'has', sub { |
22
|
32
|
|
|
32
|
|
22701
|
my $orig = shift; |
23
|
32
|
|
|
|
|
47
|
my $name = shift; |
24
|
32
|
|
|
|
|
300
|
my %attrs = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$orig->( $name, @_, trigger => sub { |
27
|
3
|
|
|
|
|
158
|
my $self = shift; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
100
|
$self->{attr}->{$name} = $attrs{isa}; |
30
|
32
|
|
|
|
|
186
|
} ); |
31
|
6
|
|
|
|
|
48
|
}); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub to_hash { |
35
|
2
|
|
|
2
|
0
|
4
|
my ($self) = @_; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
3
|
my %hash; |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
39
|
ATTR: |
40
|
2
|
|
|
|
|
3
|
for my $attr ( keys %{ $self->attr } ) { |
41
|
2
|
|
|
|
|
675
|
my $method = $self->can( $attr ); |
42
|
|
|
|
|
|
|
|
43
|
2
|
50
|
|
|
|
8
|
next ATTR if !$method; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
7
|
my $value = $self->$method(); |
46
|
|
|
|
|
|
|
|
47
|
2
|
50
|
33
|
|
|
21
|
if ( |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
!defined $value |
49
|
|
|
|
|
|
|
|| ( ref $value eq 'ARRAY' and !defined $value->[0] ) |
50
|
|
|
|
|
|
|
|| ( ref $value eq 'HASH' and !keys %{$value} ) |
51
|
|
|
|
|
|
|
) { |
52
|
0
|
|
|
|
|
0
|
next ATTR; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
7
|
$hash{$attr} = $value; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
11
|
return \%hash; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |