Added wrapper functionality
[gitmo/MooseX-Types.git] / t / lib / TestWrapper.pm
CommitLineData
c20dc98b 1package TestWrapper;
2use strict;
3use warnings;
4
5use Class::C3;
6use base 'MooseX::TypeLibrary::Wrapper';
7
8sub type_export_generator {
9 my $class = shift;
10 my ($type, $full) = @_;
11 my $code = $class->next::method(@_);
12 return sub { $code->(@_) };
13}
14
15sub check_export_generator {
16 my $class = shift;
17 my ($type, $full, $undef_msg) = @_;
18 my $code = $class->next::method(@_);
19 return sub {
20 return $code unless @_;
21 return $code->(@_);
22 };
23}
24
25sub coercion_export_generator {
26 my $class = shift;
27 my ($type, $full, $undef_msg) = @_;
28 my $code = $class->next::method(@_);
29 return sub {
30 my $val = $code->(@_);
31 die "coercion returned undef\n" unless defined $val;
32 return $val;
33 };
34}
35
361;