line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
157
|
|
2
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
343
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package MooseX::AttributeIndexes::Provider::FromAttributes; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
4
|
|
|
4
|
|
148
|
$MooseX::AttributeIndexes::Provider::FromAttributes::AUTHORITY = 'cpan:KENTNL'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$MooseX::AttributeIndexes::Provider::FromAttributes::VERSION = '1.0.3'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: A Glue-on-role that provides attribute_indexes data to a class via harvesting attribute traits |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# $Id:$ |
15
|
4
|
|
|
4
|
|
23
|
use Moose::Role; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
34
|
|
16
|
4
|
|
|
4
|
|
32141
|
use Scalar::Util qw( blessed reftype ); |
|
4
|
|
|
|
|
39
|
|
|
4
|
|
|
|
|
285
|
|
17
|
4
|
|
|
4
|
|
33
|
use namespace::autoclean; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
44
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub attribute_indexes { |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
1
|
20532
|
my $self = shift; |
23
|
5
|
|
|
|
|
35
|
my $meta = $self->meta(); |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
107
|
my $k = {}; |
26
|
|
|
|
|
|
|
|
27
|
5
|
|
|
|
|
105
|
for my $attr_name ( $meta->get_attribute_list ) { |
28
|
9
|
|
|
|
|
92
|
my $attr = $meta->get_attribute($attr_name); |
29
|
|
|
|
|
|
|
|
30
|
9
|
50
|
|
|
|
97
|
if ( $attr->does('MooseX::AttributeIndexes::Meta::Attribute::Trait::Indexed') ) { |
31
|
9
|
|
|
|
|
4516
|
my $indexed = $attr->primary_index; |
32
|
9
|
|
100
|
|
|
345
|
$indexed ||= $attr->indexed; |
33
|
9
|
|
|
|
|
13
|
my $result; |
34
|
9
|
100
|
|
|
|
24
|
if ($indexed) { |
35
|
7
|
|
|
|
|
47
|
$result = $attr->get_value($self); |
36
|
|
|
|
|
|
|
} |
37
|
9
|
100
|
66
|
|
|
911
|
if ( not blessed($indexed) |
|
|
|
66
|
|
|
|
|
38
|
|
|
|
|
|
|
and defined reftype($indexed) |
39
|
|
|
|
|
|
|
and reftype($indexed) eq 'CODE' ) |
40
|
|
|
|
|
|
|
{ |
41
|
2
|
|
|
|
|
4
|
local $_ = $result; |
42
|
2
|
|
|
|
|
7
|
$result = $attr->$indexed( $self, $result ); |
43
|
|
|
|
|
|
|
} |
44
|
9
|
100
|
|
|
|
34
|
if ($result) { |
45
|
7
|
|
|
|
|
41
|
$k->{$attr_name} = $result; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
5
|
|
|
|
|
41
|
return $k; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
MooseX::AttributeIndexes::Provider::FromAttributes - A Glue-on-role that provides attribute_indexes data to a class via harvesting attribute traits |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 VERSION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
version 1.0.3 |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 C<attribute_indexes> |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
A very trivial scanner, which looks for the |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
C<indexed> and C<primary_index> keys and returns a hashref of |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
key->value pairs ( circumventing the getter ) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHORS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over 4 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Kent Fredric. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
94
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |