#use strict;
use Moose::Util::TypeConstraints;
+use MooseX::Types::TypeDecorator;
use MooseX::Types::Base ();
use MooseX::Types::Util qw( filter_tags );
use MooseX::Types::UndefinedType;
sub type_export_generator {
my ($class, $type, $full) = @_;
- return sub {
- return find_type_constraint($full)
- || MooseX::Types::UndefinedType->new($full);
+ return sub {
+ my @args = @_;
+ use Data::Dump qw/dump/; warn @args;
+ my $type_constraint = find_type_constraint($full)
+ || MooseX::Types::UndefinedType->new($full);
+ return MooseX::Types::TypeDecorator->new(type_constraint=>$type_constraint);
};
}
--- /dev/null
+package MooseX::Types::TypeDecorator;
+
+use Moose;
+use Moose::Util::TypeConstraints;
+use Moose::Meta::TypeConstraint ();
+
+use overload(
+ '""' => sub {
+ shift->type_constraint->name;
+ },
+);
+
+=head1 NAME
+
+MooseX::Types::TypeDecorator - More flexible access to a Type Constraint
+
+=head1 DESCRIPTION
+
+This is a decorator object that contains an underlying type constraint. We use
+this to control access to the type constraint and to add some features.
+
+=head1 TYPES
+
+The following types are defined in this class.
+
+=head2 Moose::Meta::TypeConstraint
+
+Used to make sure we can properly validate incoming type constraints.
+
+=cut
+
+class_type 'Moose::Meta::TypeConstraint';
+
+=head2 MooseX::Types::UndefinedType
+
+Used since sometimes our constraint is an unknown type.
+
+=cut
+
+class_type 'MooseX::Types::UndefinedType';
+
+=head1 ATTRIBUTES
+
+This class defines the following attributes
+
+=head2 type_constraint
+
+This is the type constraint that we are delegating
+
+=cut
+
+has 'type_constraint' => (
+ is=>'ro',
+ isa=>'Moose::Meta::TypeConstraint|MooseX::Types::UndefinedType',
+ handles=>[
+ Moose::Meta::TypeConstraint->meta->compute_all_applicable_methods,
+ "_compiled_type_constraint",
+ ],
+);
+
+=head1 METHODS
+
+This class defines the following methods.
+
+=head1 AUTHOR AND COPYRIGHT
+
+John Napiorkowski (jnapiorkowski) <jjnapiork@cpan.org>
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify
+it under the same terms as perl itself.
+
+=cut
+
+1;