From: Matt S Trout Date: Fri, 18 May 2012 13:43:58 +0000 (+0000) Subject: update documentation and simplify invocant selection X-Git-Tag: v0.32~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types.git;a=commitdiff_plain;h=989b05700d2f7f091f29a395c9d8789d429ab74a update documentation and simplify invocant selection --- diff --git a/lib/MooseX/Types/TypeDecorator.pm b/lib/MooseX/Types/TypeDecorator.pm index 943bcd6..febb46a 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,9 @@ 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 call the class' version of the method if present, and fall +back to the type's version if not. =cut @@ -187,15 +190,8 @@ sub _try_delegate { } } - my $inv = ( - $class - ? ( - $method eq 'new' || $class->can($method) - ? $class - : $tc - ) - : $tc - ); + my $inv = ($class && $class->can($method)) ? $class : $tc; + $inv->$method(@args); }