« MouseX/NativeTraits/MethodProvider/HashRef.pm
↑ Summary
MouseX/NativeTraits/MethodProvider/ArrayRef.pm »
| 1 | package MouseX::NativeTraits::MethodProvider; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 19 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 19 | has attr => ( | |||||||||||||||||||||||||||||||||||||||||
| 5 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 6 | isa => 'Object', | ||||||||||||||||||||||||||||||||||||||||||
| 7 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 8 | weak_ref => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 9 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 19 | has reader => ( | |||||||||||||||||||||||||||||||||||||||||
| 12 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 19 | has writer => ( | |||||||||||||||||||||||||||||||||||||||||
| 18 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 62 | ▶ | sub _build_reader { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_reader: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 62 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 62 | return $self->attr->get_read_method_ref; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 53 | ▶ | sub _build_writer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_writer: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 53 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 53 | return $self->attr->get_write_method_ref; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 527 | ▶ | sub has_generator { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_generator: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 527 | my($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 527 | return $self->meta->has_method("generate_$name"); | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 526 | ▶ | sub generate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
generate: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 526 | my($self, $handle_name, $method_to_call) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 526 | my @curried_args; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 526 | ($method_to_call, @curried_args) = @{$method_to_call}; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 526 | my $code = $self->meta | |||||||||||||||||||||||||||||||||||||||||
| 45 | ->get_method_body("generate_$method_to_call")->($self); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 526 | ▶ | if(@curried_args){ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 23 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
unshift_curried: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 23 | my $instance = shift; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 23 | $code->($instance, @curried_args, @_); | |||||||||||||||||||||||||||||||||||||||||
| 51 | 171 | }; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | else{ | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 355 | return $code; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | sub get_generators { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_generators: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return grep{ s/\A generate_ //xms } $self->meta->get_method_list; | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 620 | ▶ | sub argument_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
argument_error: called CC=9 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 620 | my($self, $name, $min, $max, $nargs) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 620 | ▶ | if(not defined $max) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 10 | $max = 9 ** 9 ** 9; # inifinity :p | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | # fix numbers for $self | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 620 | $min--; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 620 | $max--; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 620 | $nargs--; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 620 | ▶ | if($min <= $nargs and $nargs <= $max) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$min <= $nargs and $nargs <= $max
MC/DC0%0/2
$min <= $nargs and $nargs <= $max
$min <= $nargs
$nargs <= $max
Truth table66%2/3
A and B
A= $min <= $nargsB= $nargs <= $max
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | Carp::croak("Oops ($name): nags=$nargs, min=$min, max=$max"); | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 620 | my $message = 'Cannot call %s %s argument%s'; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 620 | ▶ | if($min == 0 and $max == 0 && $nargs > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$min == 0 and ($max == 0 and $nargs > 0)
$max == 0 and $nargs > 0
MC/DC66%2/3
$min == 0 and ($max == 0 and $nargs > 0)
$min == 0
$max == 0
$nargs > 0
Truth table75%3/4
A and B and C
A= $min == 0B= $max == 0C= $nargs > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 180 | $self->meta->throw_error( | |||||||||||||||||||||||||||||||||||||||||
| 84 | sprintf $message, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | $name, 'with any', 's' ); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | $self->meta->throw_error( | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 440 | ▶ | sprintf 'Cannot call %s %s %d argument%s', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | $name, ($nargs < $min | ||||||||||||||||||||||||||||||||||||||||||
| 91 | ? ('without at least', $min) | ||||||||||||||||||||||||||||||||||||||||||
| 92 | : ('with more than', $max) ), | ||||||||||||||||||||||||||||||||||||||||||
| 93 | $nargs == 1 ? '' : 's' ); | ||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 19 | ▶ | no Mouse; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 19 | __PACKAGE__->meta->make_immutable(strict_constructor => 1); | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | __END__ | ||||||||||||||||||||||||||||||||||||||||||