line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BackPAN::Index::Role::AsHash; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
6239118
|
use Mouse::Role; |
|
16
|
|
|
|
|
54770
|
|
|
16
|
|
|
|
|
82
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
requires qw(data_methods); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub as_hash { |
8
|
3
|
|
|
3
|
1
|
592897
|
my $self = shift; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
|
|
10
|
my %data; |
11
|
3
|
|
|
|
|
23
|
for my $method ($self->data_methods) { |
12
|
17
|
|
|
|
|
19737
|
$data{$method} = $self->$method; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
135
|
return \%data; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
BackPAN::Index::Role::AsHash - Role to dump object data as a hash |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use BackPAN::Index::Role::AsHash; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub data_methods { return qw(list of data methods) } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
A role to implement C<> in result objects. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 Requires |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
The receiving class must implement... |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head3 data_methods |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my @methods = $self->data_methods; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Returns a list of methods which get data about the object. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 Implements |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head3 as_hash |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $hash = $self->as_hash; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Produces a hash reference representing the object's data based on |
50
|
|
|
|
|
|
|
C<<$self->data_methods>>. Each key is a method name, the value is |
51
|
|
|
|
|
|
|
C<<$self->$method>>. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |