File Coverage

blib/lib/MooseX/Meta/TypeCoercion/Structured/Optional.pm
Criterion Covered Total %
statement 9 14 64.2
branch 0 2 0.0
condition n/a
subroutine 3 6 50.0
pod 2 3 66.6
total 14 25 56.0


line stmt bran cond sub pod time code
1             package ## Hide from PAUSE
2             MooseX::Meta::TypeCoercion::Structured::Optional;
3              
4             our $VERSION = '0.36';
5              
6 19     19   133 use Moose;
  19         52  
  19         113  
7             extends 'Moose::Meta::TypeCoercion';
8              
9             sub compile_type_coercion {
10 14     14 0 6440 my ($self) = @_;
11 14         363 my $constraint = $self->type_constraint->type_parameter;
12              
13             $self->_compiled_type_coercion(sub {
14 0     0     my ($value) = @_;
15 0 0         return unless $constraint->has_coercion;
16 0           return $constraint->coerce($value);
17 14         953 });
18             }
19              
20 0     0 1   sub has_coercion_for_type { 0 }
21              
22             sub add_type_coercions {
23 0     0 1   Moose->throw_error("Cannot add additional type coercions to Optional types");
24             }
25              
26 19     19   111466 no Moose;
  19         52  
  19         105  
27             __PACKAGE__->meta->make_immutable(inline_constructor => 0);
28              
29             1;