From: Shawn M Moore Date: Tue, 10 Jun 2008 03:10:27 +0000 (+0000) Subject: Moose compat: no longer an error to have a trigger on a readonly attribute X-Git-Tag: 0.04~61 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=8473108059ddb46644a679a32f6e9bae8d9fd73c Moose compat: no longer an error to have a trigger on a readonly attribute --- diff --git a/lib/Mouse/Attribute.pm b/lib/Mouse/Attribute.pm index de19f3c..c086b40 100644 --- a/lib/Mouse/Attribute.pm +++ b/lib/Mouse/Attribute.pm @@ -143,9 +143,6 @@ sub create { confess "You cannot have lazy attribute ($name) without specifying a default value for it" if $args{lazy} && !exists($args{default}) && !exists($args{builder}); - confess "Trigger is not allowed on read-only attribute '$name'" - if $args{trigger} && $args{is} ne 'rw'; - confess "References are not allowed as default values, you must wrap the default of '$name' in a CODE reference (ex: sub { [] } and not [])" if ref($args{default}) && ref($args{default}) ne 'CODE'; diff --git a/t/016-trigger.t b/t/016-trigger.t index 9ce32b8..d316599 100644 --- a/t/016-trigger.t +++ b/t/016-trigger.t @@ -19,12 +19,12 @@ do { }, ); - ::throws_ok { + ::lives_ok { has error => ( is => 'ro', trigger => sub { }, ); - } qr/Trigger is not allowed on read-only attribute 'error'/; + } "it's no longer an error to have trigger on a readonly attribute"; }; can_ok(Class => 'attr');