File Coverage

blib/lib/KiokuDB/Backend/Role/Query/GIN.pm
Criterion Covered Total %
statement 17 17 100.0
branch 1 2 50.0
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package KiokuDB::Backend::Role::Query::GIN;
4 1     1   788 use Moose::Role;
  1         3  
  1         11  
5              
6 1     1   6847 use namespace::clean -except => 'meta';
  1         2  
  1         12  
7              
8             with qw(
9             Search::GIN::Extract
10             Search::GIN::Driver
11             );
12              
13             has distinct => (
14             isa => "Bool",
15             is => "rw",
16             default => 0, # FIXME what should the default be?
17             );
18              
19             sub search {
20 3     3 0 8 my ( $self, $query, @args ) = @_;
21              
22 3         79 my %args = (
23             distinct => $self->distinct,
24             @args,
25             );
26              
27 3         15 my @spec = $query->extract_values($self);
28              
29 3         619 my $ids = $self->fetch_entries(@spec);
30              
31 3 50       492 $ids = unique($ids) if $args{distinct};
32              
33 3     3   17 return $ids->filter(sub {[ $self->get(@$_) ]});
  3         205  
34             }
35              
36             sub search_filter {
37 3     3 0 4 my ( $self, $objects, $query, @args ) = @_;
38 3     3   24 return $objects->filter(sub { [ grep { $query->consistent($self, $_) } @$_ ] });
  3         104  
  7         573  
39             }
40              
41             __PACKAGE__
42              
43             __END__