From: Shawn M Moore Date: Wed, 16 Jul 2008 05:44:28 +0000 (+0000) Subject: Canonicalize the coderef version of trigger to a hashref version X-Git-Tag: 0.19~256 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=506db55746832b617f871f2e9b7429c68452f710;p=gitmo%2FMouse.git Canonicalize the coderef version of trigger to a hashref version --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 050ec49..023ab4d 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -256,9 +256,17 @@ sub validate_args { && $args->{isa} ne 'ArrayRef' && $args->{isa} ne 'HashRef'; - confess "Trigger must be a CODE or HASH ref on attribute ($name)" - if $args{trigger} - && ref($args{trigger}) ne 'CODE' && ref($args{trigger}) ne 'HASH'; + if ($args->{trigger}) { + if (ref($args->{trigger}) eq 'CODE') { + $args->{trigger} = { + after => $args->{trigger}, + }; + } + + confess "Trigger must be a CODE or HASH ref on attribute ($name)" + if $args->{trigger} + && ref($args->{trigger}) ne 'HASH'; + } return 1; }