Also see Moose::Manual::Delta for more details of, and workarounds
for, noteworthy changes.
+0.XX
+ * Moose::Meta::Attribute
+ - When adding an attribute to a metaclass, if the attribute has no
+ methods associated with, it will give a deprecation warning. (hdp)
+
0.83 Tue, Jun 23, 2009
* Moose::Meta::Class
- Fix _construct_instance not setting the special __MOP__ object
my $self = shift;
$self->SUPER::install_accessors(@_);
$self->install_delegation if $self->has_handles;
+ unless (
+ # XXX handles should be in associated_methods
+ $self->has_handles
+ || @{ $self->associated_methods }
+ || ($self->_is_metadata || '') eq 'bare'
+ ) {
+ Carp::cluck(
+ 'Attribute (' . $self->name . ') has no associated methods'
+ . ' (did you mean to provide an "is" argument?)'
+ . "\n"
+ )
+ }
return;
}
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use Moose ();
+use Moose::Meta::Class;
+
+my $meta = Moose::Meta::Class->create_anon_class;
+
+my $warn;
+$SIG{__WARN__} = sub { $warn = "@_" };
+
+$meta->add_attribute('foo');
+like $warn, qr/Attribute \(foo\) has no associated methods/,
+ 'correct error message';
+
+$warn = '';
+$meta->add_attribute('bar', is => 'bare');
+is $warn, '', 'add attribute with no methods and is => "bare"';