MouseX/NativeTraits.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 85.7% 12 / 14 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 90.9% 60 / 66 CC 9 SCAR 13.1
CC
9
Cov
93%
__ANON__
5.1
__ANON__
5.0
BEGIN
1.0
CRAP 3.7
« MouseX/NativeTraits/MethodProvider/ArrayRef.pm ↑ Summary MouseX/NativeTraits/MethodProvider/Counter.pm »
1 package MouseX::NativeTraits;
2 19 ▶use 5.006_002;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 19 ▶use Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 19 our $VERSION = '1.09';
6  
7 19 requires qw(method_provider_class helper_type);
8  
9 #has default => (
10 # is => 'bare', # don't create new methods
11 # required => 1,
12 #);
13 19 has type_constraint => (
14 is => 'bare', # don't create new methods
15 required => 1,
16 );
17  
18 19 has method_provider => (
19 is => 'ro',
20 isa => 'Object',
21  
22 builder => '_build_method_provider',
23 );
24  
25 64 ▶sub _build_method_provider{
Subroutine _build_method_provider: called CC=1 SCAR=0.0
26 64 my($self) = @_;
27 64 my $mpc = $self->method_provider_class;
28 64 Mouse::Util::load_class($mpc);
29 64 return $mpc->new(attr => $self);
30 }
31  
32 65 ▶before _process_options => sub {
Subroutine __ANON__: called CC=5 SCAR=16.2
33 65 my ( $self, $name, $options ) = @_;
34  
35 65 my $type = $self->helper_type;
36  
37 $options->{isa} = $type
38 65 ▶ if !exists $options->{isa};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options->{"isa"} 2 63 65
39  
40 my $isa = Mouse::Util::TypeConstraints::find_or_create_isa_type_constraint(
41 65 $options->{isa} );
42  
43 65 ▶ ( $isa->is_a_type_of($type) )
Branch: 1 branch
BranchTrueFalseTotal
$isa->is_a_type_of($type) or $self->throw_error("The type constraint for $name must be a subtype of $type but it's a $isa") 64 1 65
44 || $self->throw_error(
45 "The type constraint for $name must be a subtype of $type but it's a $isa");
46  
47 $options->{default} = $self->_default_default
48 64 ▶ if !exists $options->{default} && $self->can('_default_default');
Branch: 1 branch
BranchTrueFalseTotal
if not exists $options->{"default"} and $self->can("_default_default") 0 64 64
Condition66%2/3
not exists $options->{"default"} and $self->can("_default_default")
!ll&&!rl&&r
48160
MC/DC0%0/2
not exists $options->{"default"} and $self->can("_default_default")
not exists $options->{"default"} $self->can("_default_default")
Truth table66%2/3
not(A) and B
A= not exists $options->{"default"}B= $self->can("_default_default")
ABresult
0X0
100
111
49 19 };
50  
51 63 ▶around _canonicalize_handles => sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
52 63 my($next, $self) = @_;
53 63 my $handles_ref = $self->handles;
54 63 ▶ if( ref($handles_ref) ne 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $handles_ref ne "HASH") 0 63 63
55 0 $self->throw_error(
56 "The 'handles' option must be a HASH reference, not $handles_ref");
57 }
58  
59 63 my $provider = $self->method_provider;
60  
61 63 my %handles;
62 63 ▶ while(my($name, $to) = each %{$handles_ref}){
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$handles_ref;}) 527 62 589
63 527 ▶ $to = [$to] if !ref $to;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $to 356 171 527
64 527 ▶ $provider->has_generator($to->[0])
Branch: 1 branch
BranchTrueFalseTotal
$provider->has_generator($to->[0]) or $self->throw_error("$to->[0] is an unsupported method type") 526 1 527
65 or $self->throw_error("$to->[0] is an unsupported method type");
66 526 $handles{$name} = $to;
67 }
68  
69 62 return %handles;
70 19 };
71  
72 526 ▶around _make_delegation_method => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
73 526 my( $next, $self, $handle_name, $method_to_call) = @_;
74 526 return $self->method_provider->generate($handle_name, $method_to_call);
75 19 };
76  
77 19 ▶no Mouse::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
78 19 1;
79 __END__
« MouseX/NativeTraits/MethodProvider/ArrayRef.pm ↑ Summary MouseX/NativeTraits/MethodProvider/Counter.pm »