blib/lib/Data/Shared/Adapter/Sketch.pm

filter: Statementstmt 90.7% 49 / 54 Branchbran 93.7% 15 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 12 / 15 Podpod 0.0% 0 / 4 totaltotal 85.3% 76 / 89 CC 9 SCAR 9.0
CC
9
Cov
91%
make_bound
4.1
make_verb
4.0
_key
3.0
CRAP 2.5
« blib/lib/Data/Shared/Node.pm ↑ Summary blib/lib/Data/Shared/Compiled.pm »
1 package Data::Shared::Adapter::Sketch;
2 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use parent 'Data::Shared::Adapter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 40 our $VERSION = '0.02';
8  
9 40 our @CARP_NOT = qw(Data::Shared);
10  
11 32 ▶sub _key {
Subroutine _key: called CC=3 SCAR=11.0
12 32 my ($entry, $rest) = @_;
13 32 ▶ Carp::croak("Data::Shared: path too short: mount has no key") unless @$rest;
Branch: 1 branch
BranchTrueFalseTotal
unless @$rest 2 30 32
14 30 ▶ Carp::croak("Data::Shared: path too long: $entry->{key} takes one key component")
Branch: 1 branch
BranchTrueFalseTotal
if @$rest > 1 1 29 30
15 if @$rest > 1;
16 29 return $rest->[0];
17 }
18  
19 25 ▶sub make_verb {
Subroutine make_verb: called CC=4 SCAR=13.9
Pod undocumented
20 25 my ($class, $verb, $handle, $entry) = @_;
21 25 my $spec = Data::Shared::Adapter::_spec($entry, $verb);
22 25 ▶ return undef unless defined $spec;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $spec 4 21 25
23 21 ▶ if (ref $spec eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $spec eq "CODE") 12 9 21
24 19 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
25 19 my ($rest, @a) = @_;
26 19 my $key = _key($entry, $rest);
27 19 return $spec->($handle, $key, @a);
28 12 };
29 }
30 9 my $method = $handle->can($spec);
31 9 ▶ if (!$method) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($method) 1 8 9
32 1 my $msg = Data::Shared::Adapter::_unsupported($entry, $handle, $spec);
33 1 ▶ return sub { Carp::croak($msg) };
Subroutine __ANON__: called CC=1 SCAR=0.0
34 }
35 10 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
36 10 my ($rest, @a) = @_;
37 10 my $key = _key($entry, $rest);
38 8 return $handle->$method($key, @a);
39 8 };
40 }
41  
42 4 ▶sub make_bound {
Subroutine make_bound: called CC=4 SCAR=14.1
Pod undocumented
43 4 my ($class, $verb, $handle, $entry, $rest) = @_;
44 4 my $spec = Data::Shared::Adapter::_spec($entry, $verb);
45 4 ▶ return undef unless defined $spec;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $spec 1 3 4
46 3 my $key = _key($entry, $rest);
47 2 ▶ if (ref $spec eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $spec eq "CODE") 1 1 2
48 1 ▶ return sub { my @a = @_; return $spec->($handle, $key, @a) };
Subroutine __ANON__: called CC=1 SCAR=0.0
49 }
50 1 my $method = $handle->can($spec);
51 1 ▶ if (!$method) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($method) 0 1 1
52 0 my $msg = Data::Shared::Adapter::_unsupported($entry, $handle, $spec);
53 0 ▶ return sub { Carp::croak($msg) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
54 }
55 1 ▶ return sub { my @a = @_; return $handle->$method($key, @a) };
Subroutine __ANON__: called CC=1 SCAR=0.0
56 }
57  
58 0 ▶sub perform_push { Carp::croak("Data::Shared: push is not supported for sketch mounts (use shared_call)") }
Subroutine perform_push: not called CC=1 SCAR=6.9
Pod undocumented
59 0 ▶sub perform_pop { Carp::croak("Data::Shared: pop is not supported for sketch mounts (use shared_call)") }
Subroutine perform_pop: not called CC=1 SCAR=6.9
Pod undocumented
60  
61 40 1;
62  
63 __END__
« blib/lib/Data/Shared/Node.pm ↑ Summary blib/lib/Data/Shared/Compiled.pm »