hide more from PAUSE indexer
[gitmo/MooseX-Types-Structured.git] / lib / MooseX / Meta / TypeCoercion / Structured / Optional.pm
CommitLineData
3c0a590c 1package ## Hide from PAUSE
2 MooseX::Meta::TypeCoercion::Structured::Optional;
abd193e2 3
4use Moose;
5extends 'Moose::Meta::TypeCoercion';
6
8dbdca20 7=method compile_type_coercion
8
9=cut
10
abd193e2 11sub compile_type_coercion {
12 my ($self) = @_;
13 my $constraint = $self->type_constraint->type_parameter;
14
15 $self->_compiled_type_coercion(sub {
16 my ($value) = @_;
17 return unless $constraint->has_coercion;
18 return $constraint->coerce($value);
19 });
20}
21
22sub has_coercion_for_type { 0 }
23
24sub add_type_coercions {
25 Moose->throw_error("Cannot add additional type coercions to Optional types");
26}
27
28__PACKAGE__->meta->make_immutable(inline_constructor => 0);
29
301;