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