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