is currently not supported in roles,
but, ... patches welcome
+ * Moose::Meta::Attribute
+ - trigger on a ro-attribute is no longer an
+ error, as it's useful to trigger off of the
+ constructor
+
* Moose::Meta::Class
- added same 'add_package_symbol' fix as in
Class::MOP 0.56
if (exists $options->{is}) {
if ($options->{is} eq 'ro') {
$options->{reader} ||= $name;
- (!exists $options->{trigger})
- || confess "Cannot have a trigger on a read-only attribute $name";
}
elsif ($options->{is} eq 'rw') {
$options->{accessor} = $name;
- ((reftype($options->{trigger}) || '') eq 'CODE')
- || confess "Trigger must be a CODE ref"
- if exists $options->{trigger};
}
else {
confess "I do not understand this option (is => " . $options->{is} . ") on attribute $name"
if $options->{weak_ref};
}
+ if (exists $options->{trigger}) {
+ (reftype($options->{trigger}) || '') eq 'CODE'
+ || confess "Trigger must be a CODE ref";
+ }
+
if (exists $options->{auto_deref} && $options->{auto_deref}) {
(exists $options->{type_constraint})
|| confess "You cannot auto-dereference without specifying a type constraint on attribute $name";
use Scalar::Util 'isweak';
-use Test::More tests => 27;
+use Test::More tests => 26;
use Test::Exception;
BEGIN {
use Moose;
::dies_ok {
- has('bling' => (is => 'ro', trigger => sub { 0 }));
- } '... cannot create trigger on a read-only attr';
-}
-
-{
- package Bling::Bling;
- use Moose;
-
- ::dies_ok {
has('bling' => (is => 'rw', trigger => 'Fail'));
} '... a trigger must be a CODE ref';