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 20     20   110 use Moose;
  20         36  
  20         145  
5             extends 'Moose::Meta::TypeCoercion';
6              
7             sub compile_type_coercion {
8 14     14 0 6662 my ($self) = @_;
9 14         427 my $constraint = $self->type_constraint->type_parameter;
10              
11             $self->_compiled_type_coercion(sub {
12 0     0     my ($value) = @_;
13 0 0         return unless $constraint->has_coercion;
14 0           return $constraint->coerce($value);
15 14         1250 });
16             }
17              
18 0     0 1   sub has_coercion_for_type { 0 }
19              
20             sub add_type_coercions {
21 0     0 1   Moose->throw_error("Cannot add additional type coercions to Optional types");
22             }
23              
24 20     20   127075 no Moose;
  20         44  
  20         100  
25             __PACKAGE__->meta->make_immutable(inline_constructor => 0);
26              
27             1;