Added wrapper functionality
[gitmo/MooseX-Types.git] / t / lib / TestWrapper.pm
1 package TestWrapper;
2 use strict;
3 use warnings;
4
5 use Class::C3;
6 use base 'MooseX::TypeLibrary::Wrapper';
7
8 sub type_export_generator {
9     my $class = shift;
10     my ($type, $full) = @_;
11     my $code = $class->next::method(@_);
12     return sub { $code->(@_) };
13 }
14
15 sub 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
25 sub 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
36 1;