line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
1937375
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
150
|
|
2
|
4
|
|
|
4
|
|
25
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
227
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package MooseX::AttributeIndexes; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
4
|
|
|
4
|
|
141
|
$MooseX::AttributeIndexes::AUTHORITY = 'cpan:KENTNL'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$MooseX::AttributeIndexes::VERSION = '1.0.3'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Advertise metadata about your Model-Representing Classes to Any Database tool. |
13
|
4
|
|
|
4
|
|
967
|
use Moose 0.94 (); |
|
4
|
|
|
|
|
505810
|
|
|
4
|
|
|
|
|
105
|
|
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
29
|
use Moose::Exporter; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
36
|
|
16
|
4
|
|
|
4
|
|
214
|
use Moose::Util::MetaRole; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
104
|
|
17
|
4
|
|
|
4
|
|
7686
|
use MooseX::AttributeIndexes::Provider; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
164
|
|
18
|
4
|
|
|
4
|
|
3516
|
use MooseX::AttributeIndexes::Provider::FromAttributes; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
162
|
|
19
|
4
|
|
|
4
|
|
3431
|
use MooseX::AttributeIndexes::Meta::Attribute::Trait::Indexed; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
621
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( |
24
|
|
|
|
|
|
|
class_metaroles => { |
25
|
|
|
|
|
|
|
attribute => ['MooseX::AttributeIndexes::Meta::Attribute::Trait::Indexed'], |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
role_metaroles => { |
28
|
|
|
|
|
|
|
( |
29
|
|
|
|
|
|
|
Moose->VERSION >= 1.9900 |
30
|
|
|
|
|
|
|
? ( applied_attribute => ['MooseX::AttributeIndexes::Meta::Attribute::Trait::Indexed'] ) |
31
|
|
|
|
|
|
|
: () |
32
|
|
|
|
|
|
|
), |
33
|
|
|
|
|
|
|
role => ['MooseX::AttributeIndexes::Meta::Role'], |
34
|
|
|
|
|
|
|
application_to_class => [ 'MooseX::AttributeIndexes::Meta::Role::ApplicationToClass', ], |
35
|
|
|
|
|
|
|
application_to_role => [ 'MooseX::AttributeIndexes::Meta::Role::ApplicationToRole', ], |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
base_class_roles => [ 'MooseX::AttributeIndexes::Provider', 'MooseX::AttributeIndexes::Provider::FromAttributes', ], |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=pod |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
MooseX::AttributeIndexes - Advertise metadata about your Model-Representing Classes to Any Database tool. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 VERSION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
version 1.0.3 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 Implementing Indexes |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
package My::Package; |
59
|
|
|
|
|
|
|
use Moose; |
60
|
|
|
|
|
|
|
use MooseX::AttributeIndexes; |
61
|
|
|
|
|
|
|
use MooseX::Types::Moose qw( :all ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has 'id' => ( |
64
|
|
|
|
|
|
|
isa => Str, |
65
|
|
|
|
|
|
|
is => 'rw', |
66
|
|
|
|
|
|
|
primary_index => 1, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has 'name' => ( |
70
|
|
|
|
|
|
|
isa => Str, |
71
|
|
|
|
|
|
|
is => 'rw', |
72
|
|
|
|
|
|
|
indexed => 1, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
has 'foo' => ( |
76
|
|
|
|
|
|
|
isa => Str, |
77
|
|
|
|
|
|
|
is => 'rw', |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 Accessing Indexed Data |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package TestScript; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
use My::Package; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $foo = My::Package->new( |
87
|
|
|
|
|
|
|
id => "Bob", |
88
|
|
|
|
|
|
|
name => "Smith", |
89
|
|
|
|
|
|
|
foo => "Bar", |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$foo->attribute_indexes |
93
|
|
|
|
|
|
|
# { id => 'Bob', name => 'Smith' } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 Using With Search::GIN::Extract::Callback |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Search::GIN::Extract::Callback( |
98
|
|
|
|
|
|
|
extract => sub { |
99
|
|
|
|
|
|
|
my ( $obj, $callback, $args ) = @_; |
100
|
|
|
|
|
|
|
if( $obj->does( 'MooseX::AttributeIndexes::Provider') ){ |
101
|
|
|
|
|
|
|
return $obj->attribute_indexes; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 CODERef |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Since 0.01001007, the following notation is also supported: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
has 'name' => ( |
111
|
|
|
|
|
|
|
... |
112
|
|
|
|
|
|
|
indexed => sub { |
113
|
|
|
|
|
|
|
my ( $attribute_meta, $object, $value ) = @_; |
114
|
|
|
|
|
|
|
return "$_" ; # $_ == $value |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Noting of course, $value is populated by the meta-accessor. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This is a simple way to add exceptions for weird cases for things you want to index that |
121
|
|
|
|
|
|
|
don't behave like they should. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head3 SEE ALSO |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L<Search::GIN::Extract::AttributeIndexes> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHORS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over 4 |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=back |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Kent Fredric. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
146
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=cut |