lib/Reaction/InterfaceModel/Search/Spec.pm

filter: Statementstmt 40.9% 34 / 83 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 52.3% 11 / 21 Podpod n/a totaltotal 39.4% 45 / 114 CC 8 SCAR 13.5
CC
8
Cov
38%
__ANON__
10.3
_to_string_fetch
10.3
__ANON__
6.0
CRAP 3.9
« lib/Reaction/Class.pm ↑ Summary lib/Reaction/UI/ViewPort.pm »
1 package Reaction::InterfaceModel::Search::Spec;
2  
3 4 ▶use Reaction::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Method::Signatures::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use namespace::clean -except => [ qw(meta) ];
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 has '_search_spec' => (
10 is => 'ro', lazy_build => 1, clearer => '_clear_search_spec',
11 );
12  
13 has '_dependent_clients' => (
14 0 ▶ is => 'ro', default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 4 );
16  
17 0 ▶method register_dependent ($dep, $callback) {
Subroutine BEGIN: called CC=1 SCAR=3.5
Subroutine register_dependent: not called CC=1 SCAR=4.1
18 0 weaken($self->_dependent_clients->{$dep} = $callback);
19 4 }
20  
21 0 ▶method unregister_dependent ($dep) {
Subroutine BEGIN: called CC=1 SCAR=4.9
Subroutine unregister_dependent: not called CC=1 SCAR=5.3
Subroutine __ANON__: not called CC=1 SCAR=5.3
22 0 delete $self->_dependent_clients->{$dep};
23 4 }
24  
25 0 ▶after '_clear_search_spec' => method () {
Subroutine __ANON__: not called CC=2 SCAR=17.9
26 0 $_->($self) for grep defined, values %{$self->_dependent_clients};
27 4 };
28  
29 4 requires '_build__search_spec';
30  
31 0 ▶method filter_collection ($coll) {
Subroutine BEGIN: called CC=1 SCAR=4.6
Subroutine __ANON__: not called CC=1 SCAR=5.1
32 0 return $coll->where(@{$self->_search_spec});
33 4 }
34  
35 0 ▶method _to_string_fetch ($attr) {
Subroutine BEGIN: called CC=1 SCAR=3.5
Subroutine __ANON__: not called CC=3 SCAR=23.3
36 0 ▶ return () unless $self->${\($attr->get_predicate_method||sub{ 1 })};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless $self->${\($attr->get_predicate_method || sub { 1; } );} 0 0 0
Condition0%0/3
$attr->get_predicate_method || sub { 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$attr->get_predicate_method || sub { 1; }
$attr->get_predicate_method sub { 1; }
Truth table0%0/3
A || B
A= $attr->get_predicate_methodB= sub { 1; }
ABresult
1X1
011
000
37 0 my $value = $self->${\$attr->get_read_method};
38 0 return ($attr->name => $self->_to_string_pack_value($attr->name, $value));
39 4 }
40  
41 4 requires '_to_string_pack_value';
42  
43 0 ▶method to_string () {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine to_string: not called CC=1 SCAR=4.9
44 0 my %val = map { $self->_to_string_fetch($_) }
45 0 grep { $_->name !~ /^_/ } $self->meta->get_all_attributes;
46 0 return to_json(\%val, { canonical => 1 });
47 4 }
48  
49 4 requires '_from_string_unpack_value';
50  
51 0 ▶method from_string ($class: $string, $other) {
Subroutine BEGIN: called CC=1 SCAR=3.5
Subroutine from_string: not called CC=2 SCAR=16.4
52 0 my %raw = %{from_json($string)};
53 0 my %val;
54 @val{keys %raw} = map {
55 0 $class->_from_string_unpack_value($_, $raw{$_})
56 } keys %raw;
57 0 ▶ return $class->new({ %val, %{$other||{}} });
Condition0%0/2
$other || {}
l!l
00
MC/DC0%0/1
$other || {}
$other
Truth table0%0/2
A
A= $other
Aresult
11
00
58 4 }
59  
60 4 1;
61  
« lib/Reaction/Class.pm ↑ Summary lib/Reaction/UI/ViewPort.pm »