use Scalar::Util 'blessed', 'weaken';
use overload ();
-our $VERSION = '0.84';
+our $VERSION = '0.88';
our $AUTHORITY = 'cpan:STEVAN';
use Moose::Meta::Method::Accessor;
documentation lazy handles
builder type_constraint
definition_context
- lazy_build
+ lazy_build weak_ref
);
sub legal_options_for_inheritance { @legal_options_for_inheritance }
my $meta_instance = Class::MOP::Class->initialize(blessed($instance))
->get_meta_instance;
+ my @old;
+ if ( $self->has_trigger && $self->has_value($instance) ) {
+ @old = $self->get_value($instance, 'for trigger');
+ }
+
$meta_instance->set_slot_value($instance, $attr_name, $value);
if (ref $value && $self->is_weak_ref) {
}
if ($self->has_trigger) {
- $self->trigger->($instance, $value);
+ $self->trigger->($instance, $value, @old);
}
}
sub get_value {
- my ($self, $instance) = @_;
+ my ($self, $instance, $for_trigger) = @_;
if ($self->is_lazy) {
unless ($self->has_value($instance)) {
}
}
- if ($self->should_auto_deref) {
+ if ( $self->should_auto_deref && ! $for_trigger ) {
my $type_constraint = $self->type_constraint;
return;
}
-sub check_associated_methods {
+sub _check_associated_methods {
my $self = shift;
unless (
@{ $self->associated_methods }
&& (!$self->definition_context
|| $method->package_name eq $self->definition_context->{package})) {
Carp::cluck(
- "You cannot overwrite a locally defined method ($accessor) with "
+ "You are overwriting a locally defined method ($accessor) with "
. "an accessor"
);
}
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. See L</check_associated_methods>.
+metaclass.
=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