X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FTypes%2FTypeDecorator.pm;h=4c2bc8eb1a2d02a03d8efe5e93e0f9ff93c9b926;hb=ef8b7b7a254653b0e77d19b19d7bd870700cf4b2;hp=6c6c8a1400f0a4c5dbbbebb72949878547e87ff2;hpb=3ade1c446c7ade4a07a31147a0511233be706b44;p=gitmo%2FMooseX-Types.git diff --git a/lib/MooseX/Types/TypeDecorator.pm b/lib/MooseX/Types/TypeDecorator.pm index 6c6c8a1..4c2bc8e 100644 --- a/lib/MooseX/Types/TypeDecorator.pm +++ b/lib/MooseX/Types/TypeDecorator.pm @@ -1,15 +1,21 @@ 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) { @@ -18,6 +24,7 @@ use overload( return "$self"; } }, + bool => sub { 1 }, '|' => sub { ## It's kind of ugly that we need to know about Union Types, but this @@ -45,10 +52,6 @@ use overload( ); -=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 @@ -194,7 +197,6 @@ sub AUTOLOAD { ## MooseX::Types::UndefinedType which AUTOLOADs during autovivication. my $return; - eval { $return = $self->__type_constraint->$method(@args); }; if($@) { @@ -204,10 +206,6 @@ sub AUTOLOAD { } } -=head1 AUTHOR AND COPYRIGHT - -John Napiorkowski (jnapiorkowski) - =head1 LICENSE This program is free software; you can redistribute it and/or modify