| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
2
|
|
|
2
|
|
32410
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
57
|
|
|
2
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
109
|
|
|
3
|
|
|
|
|
|
|
package Search::GIN::Query::Class; |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Create class-based GIN queries |
|
5
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
|
6
|
2
|
|
|
2
|
|
999
|
use Moose; |
|
|
2
|
|
|
|
|
727087
|
|
|
|
2
|
|
|
|
|
15
|
|
|
7
|
2
|
|
|
2
|
|
11745
|
use Carp qw(croak); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
120
|
|
|
8
|
2
|
|
|
2
|
|
1282
|
use namespace::autoclean; |
|
|
2
|
|
|
|
|
2400
|
|
|
|
2
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with qw( |
|
11
|
|
|
|
|
|
|
Search::GIN::Query |
|
12
|
|
|
|
|
|
|
Search::GIN::Keys::Deep |
|
13
|
|
|
|
|
|
|
); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has no_check => ( |
|
16
|
|
|
|
|
|
|
isa => "Bool", |
|
17
|
|
|
|
|
|
|
is => "rw", |
|
18
|
|
|
|
|
|
|
default => 0, |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has class => ( |
|
22
|
|
|
|
|
|
|
isa => "ArrayRef | Str", |
|
23
|
|
|
|
|
|
|
is => "ro", |
|
24
|
|
|
|
|
|
|
predicate => "has_class", |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has does => ( |
|
28
|
|
|
|
|
|
|
isa => "ArrayRef | Str", |
|
29
|
|
|
|
|
|
|
is => "ro", |
|
30
|
|
|
|
|
|
|
predicate => "has_does", |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has blessed => ( |
|
34
|
|
|
|
|
|
|
isa => "Str", |
|
35
|
|
|
|
|
|
|
is => "ro", |
|
36
|
|
|
|
|
|
|
predicate => "has_blessed", |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub BUILD { |
|
40
|
3
|
|
|
3
|
0
|
3
|
my $self = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
3
|
0
|
33
|
|
|
99
|
croak "One of 'class', 'does', or 'blessed' is required" |
|
|
|
|
33
|
|
|
|
|
|
43
|
|
|
|
|
|
|
unless $self->has_class or $self->has_does or $self->has_blessed; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub extract_values { |
|
47
|
3
|
|
|
3
|
0
|
3
|
my $self = shift; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return ( |
|
50
|
3
|
50
|
|
|
|
83
|
method => "all", |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
values => [ $self->process_keys({ |
|
52
|
|
|
|
|
|
|
( $self->has_class ? ( class => $self->class ) : () ), |
|
53
|
|
|
|
|
|
|
( $self->has_does ? ( does => $self->does ) : () ), |
|
54
|
|
|
|
|
|
|
( $self->has_blessed ? ( blessed => $self->blessed ) : () ), |
|
55
|
|
|
|
|
|
|
}) ], |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub consistent { |
|
60
|
9
|
|
|
9
|
0
|
10
|
my ( $self, $index, $object ) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
9
|
50
|
|
|
|
224
|
return 1 if $self->no_check; |
|
63
|
|
|
|
|
|
|
|
|
64
|
9
|
50
|
|
|
|
273
|
if ( $self->has_blessed ) { |
|
65
|
0
|
0
|
|
|
|
0
|
return unless ref($object) eq $self->blessed; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
9
|
50
|
|
|
|
245
|
if ( $self->has_class ) { |
|
69
|
9
|
50
|
|
|
|
211
|
return unless $self->check_object($object, isa => $self->class); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
9
|
50
|
|
|
|
250
|
if ( $self->has_does ) { |
|
73
|
0
|
0
|
|
|
|
0
|
return unless $self->check_object($object, DOES => $self->does); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
9
|
|
|
|
|
100
|
return 1; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub check_object { |
|
80
|
9
|
|
|
9
|
0
|
12
|
my ( $self, $object, $check, $classes ) = @_; |
|
81
|
|
|
|
|
|
|
|
|
82
|
9
|
50
|
|
|
|
15
|
my @classes = ref($classes) ? @$classes : $classes; |
|
83
|
|
|
|
|
|
|
|
|
84
|
9
|
|
|
|
|
10
|
foreach my $class ( @classes ) { |
|
85
|
9
|
50
|
|
|
|
36
|
$object->$check($class) or return; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
9
|
|
|
|
|
19
|
return 1; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=pod |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=encoding UTF-8 |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 NAME |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Search::GIN::Query::Class - Create class-based GIN queries |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 VERSION |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
version 0.10 |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
use Search::GIN::Query::Class; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $query = Search::GIN::Query::Class->new( |
|
114
|
|
|
|
|
|
|
class => 'Person', |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Creates a class-based GIN query that can be used to search records in a storage. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
This is a ready-to-use query that uses class definitions (specifically C<class>, |
|
122
|
|
|
|
|
|
|
C<does> and C<blessed>) to search through the storage. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 METHODS/SUBROUTINES |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 new |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Creates a new query. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 class |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The class of the object you want to find. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
my $query = Search::GIN::Query::Class->new( |
|
137
|
|
|
|
|
|
|
class => 'Person', |
|
138
|
|
|
|
|
|
|
); |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 does |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
A role consumed by the object you want to find. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
my $query = Search::GIN::Query::Class->new( |
|
145
|
|
|
|
|
|
|
does => 'TheMonkey', |
|
146
|
|
|
|
|
|
|
); |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 blessed |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The name of the package that the object is blessed into. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
my $query = Search::GIN::Query::Class->new( |
|
153
|
|
|
|
|
|
|
blessed => 'Person', |
|
154
|
|
|
|
|
|
|
); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 AUTHOR |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
×××× ×§××'×× (Yuval Kogman) <nothingmuch@woobling.org> |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This software is copyright (c) 2008 by ×××× ×§××'×× (Yuval Kogman), Infinity Interactive. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
165
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=cut |