From: Shawn M Moore Date: Wed, 16 Jul 2008 05:15:05 +0000 (+0000) Subject: Allow trigger to be a hashref.. :) X-Git-Tag: 0.19~258 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ca7941e5f5a56ef4e0c61835538c505645152085;p=gitmo%2FMouse.git Allow trigger to be a hashref.. :) --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 4237806..011ff4e 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -254,9 +254,9 @@ sub validate_args { && $args{isa} ne 'ArrayRef' && $args{isa} ne 'HashRef'; - confess "Trigger must be a CODE ref on attribute ($name)" + confess "Trigger must be a CODE or HASH ref on attribute ($name)" if $args{trigger} - && ref($args{trigger}) ne 'CODE'; + && ref($args{trigger}) ne 'CODE' && ref($args{trigger}) ne 'HASH'; return 1; } diff --git a/t/016-trigger.t b/t/016-trigger.t index 2a4dc94..99bf942 100644 --- a/t/016-trigger.t +++ b/t/016-trigger.t @@ -31,7 +31,7 @@ do { is => 'ro', trigger => [], ); - } qr/Trigger must be a CODE ref on attribute \(error\)/; + } qr/Trigger must be a CODE or HASH ref on attribute \(error\)/; }; can_ok(Class => 'attr');