package MooseX::Types::TypeDecorator;
+#ABSTRACT: Wraps Moose::Meta::TypeConstraint objects with added features
+
use strict;
use warnings;
-
use Carp::Clan qw( ^MooseX::Types );
use Moose::Util::TypeConstraints ();
use Moose::Meta::TypeConstraint::Union;
use Scalar::Util qw(blessed);
use overload(
+ '0+' => sub {
+ my $self = shift @_;
+ my $tc = $self->{__type_constraint};
+ return 0+$tc;
+ },
'""' => sub {
my $self = shift @_;
if(blessed $self) {
return "$self";
}
},
+ bool => sub { 1 },
'|' => sub {
## It's kind of ugly that we need to know about Union Types, but this
);
-=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
=head2 AUTOLOAD
-Delegate to the decorator targe
+Delegate to the decorator target.
=cut
## MooseX::Types::UndefinedType which AUTOLOADs during autovivication.
my $return;
-
eval {
$return = $self->__type_constraint->$method(@args);
}; if($@) {
}
}
-=head1 AUTHOR
-
-See L<MooseX::Types/AUTHOR>.
-
=head1 LICENSE
This program is free software; you can redistribute it and/or modify