X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FTypes%2FTypeDecorator.pm;h=056eff7195d4e0313d83708c342b4f511bdef81b;hb=ee3f409392f593290579acf0c12deb24a4fed153;hp=943bcd63191ac5cdcafa78a0699c2bd7dd26fb8a;hpb=6e73ec86fc0b97ac2130e57e79ebb9028eb0e973;p=gitmo%2FMooseX-Types.git diff --git a/lib/MooseX/Types/TypeDecorator.pm b/lib/MooseX/Types/TypeDecorator.pm index 943bcd6..056eff7 100644 --- a/lib/MooseX/Types/TypeDecorator.pm +++ b/lib/MooseX/Types/TypeDecorator.pm @@ -112,7 +112,8 @@ sub __type_constraint { =head2 isa -handle $self->isa since AUTOLOAD can't. +handle $self->isa since AUTOLOAD can't - this tries both the type constraint, +and for a class type, the class. =cut @@ -156,7 +157,10 @@ sub DESTROY { =head2 AUTOLOAD -Delegate to the decorator target. +Delegate to the decorator target, unless this is a class type, in which +case it will try to delegate to the type object, then if that fails try +the class. The method 'new' is special cased to go to the class first +if present. =cut @@ -187,15 +191,16 @@ sub _try_delegate { } } - my $inv = ( - $class - ? ( - $method eq 'new' || $class->can($method) - ? $class - : $tc - ) - : $tc - ); + my $inv = do { + if ($tc->can($method) and $method ne 'new') { + $tc + } elsif ($class && $class->can($method)) { + $class + } else { + $tc + } + }; + $inv->$method(@args); }