Also see Moose::Manual::Delta for more details of, and workarounds
for, noteworthy changes.
+0.85
+ * Moose::Meta::Attribute
+ - The warning for 'no associated methods' is now split out into the
+ check_associated_methods method, so that extensions can safely call
+ 'after install_accessors => ...'. (hdp)
+
0.84 Fri, Jun 26, 2009
* Moose::Role
- has now sets definition_context for attributes defined in
my $self = shift;
$self->SUPER::install_accessors(@_);
$self->install_delegation if $self->has_handles;
+ return;
+}
+
+sub check_associated_methods {
+ my $self = shift;
unless (
@{ $self->associated_methods }
|| ($self->_is_metadata || '') eq 'bare'
. "\n"
)
}
- return;
}
sub _process_accessors {
Use 'bare' when you are deliberately not installing any methods
(accessor, reader, etc.) associated with this attribute; otherwise,
Moose will issue a deprecation warning when this attribute is added to a
-metaclass.
+metaclass. See L</check_associated_methods>.
=item * isa => $type
attribute's type constraint. If the value is not valid, it throws an
error.
+=item B<< $attr->check_associated_methods >>
+
+This method makes sure that either an explicit C<< is => 'bare' >> was passed
+to the attribute's constructor or that the attribute has at least one
+associated method (reader, writer, delegation, etc.). Otherwise, it issues a
+warning.
+
=item B<< $attr->handles >>
This returns the value of the C<handles> option passed to the
sub add_attribute {
my $self = shift;
- $self->SUPER::add_attribute(
+ my $attr =
(blessed $_[0] && $_[0]->isa('Class::MOP::Attribute')
? $_[0]
- : $self->_process_attribute(@_))
- );
+ : $self->_process_attribute(@_));
+ $self->SUPER::add_attribute($attr);
+ # it may be a Class::MOP::Attribute, theoretically, which doesn't have
+ # 'bare' and doesn't implement this method
+ if ($attr->can('check_associated_methods')) {
+ $attr->check_associated_methods;
+ }
+ return $attr;
}
sub add_override_method_modifier {