| 1 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | package Search::GIN::Query::Class; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: Create class-based GIN queries | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | with qw( | |||||||||||||||||||||||||||||||||||||||||
| 13 | Search::GIN::Query | ||||||||||||||||||||||||||||||||||||||||||
| 14 | Search::GIN::Keys::Deep | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | has no_check => ( | |||||||||||||||||||||||||||||||||||||||||
| 18 | isa => "Bool", | ||||||||||||||||||||||||||||||||||||||||||
| 19 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||
| 20 | default => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | has class => ( | |||||||||||||||||||||||||||||||||||||||||
| 24 | isa => "ArrayRef | Str", | ||||||||||||||||||||||||||||||||||||||||||
| 25 | is => "ro", | ||||||||||||||||||||||||||||||||||||||||||
| 26 | predicate => "has_class", | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | has does => ( | |||||||||||||||||||||||||||||||||||||||||
| 30 | isa => "ArrayRef | Str", | ||||||||||||||||||||||||||||||||||||||||||
| 31 | is => "ro", | ||||||||||||||||||||||||||||||||||||||||||
| 32 | predicate => "has_does", | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | has blessed => ( | |||||||||||||||||||||||||||||||||||||||||
| 36 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||
| 37 | is => "ro", | ||||||||||||||||||||||||||||||||||||||||||
| 38 | predicate => "has_blessed", | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=4 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | croak "One of 'class', 'does', or 'blessed' is required" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->has_class or $self->has_does or $self->has_blessed
$self->has_class or $self->has_does
MC/DC0%0/3
$self->has_class or $self->has_does or $self->has_blessed
$self->has_class
$self->has_does
$self->has_blessed
Truth table25%1/4
A or B or C
A= $self->has_classB= $self->has_doesC= $self->has_blessed
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | unless $self->has_class or $self->has_does or $self->has_blessed; | ||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | ▶ | sub extract_values { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_values: called CC=4 SCAR=15.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | ▶ | method => "all", | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | values => [ $self->process_keys({ | ||||||||||||||||||||||||||||||||||||||||||
| 54 | ( $self->has_class ? ( class => $self->class ) : () ), | ||||||||||||||||||||||||||||||||||||||||||
| 55 | ( $self->has_does ? ( does => $self->does ) : () ), | ||||||||||||||||||||||||||||||||||||||||||
| 56 | ( $self->has_blessed ? ( blessed => $self->blessed ) : () ), | ||||||||||||||||||||||||||||||||||||||||||
| 57 | }) ], | ||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 9 | ▶ | sub consistent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
consistent: called CC=8 SCAR=27.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 9 | my ( $self, $index, $object ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 9 | ▶ | return 1 if $self->no_check; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 9 | ▶ | if ( $self->has_blessed ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | return unless ref($object) eq $self->blessed; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 9 | ▶ | if ( $self->has_class ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 9 | ▶ | return unless $self->check_object($object, isa => $self->class); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 9 | ▶ | if ( $self->has_does ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return unless $self->check_object($object, DOES => $self->does); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 9 | ▶ | sub check_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_object: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 9 | my ( $self, $object, $check, $classes ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | ▶ | my @classes = ref($classes) ? @$classes : $classes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 9 | foreach my $class ( @classes ) { | |||||||||||||||||||||||||||||||||||||||||
| 87 | 9 | ▶ | $object->$check($class) or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | __END__ | ||||||||||||||||||||||||||||||||||||||||||