use Scalar::Util 'blessed', 'weaken';
use overload ();
-our $VERSION = '0.85';
+our $VERSION = '0.91';
our $AUTHORITY = 'cpan:STEVAN';
use Moose::Meta::Method::Accessor;
));
__PACKAGE__->meta->add_attribute('handles' => (
reader => 'handles',
+ writer => '_set_handles',
predicate => 'has_handles',
));
__PACKAGE__->meta->add_attribute('documentation' => (
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;
(blessed $role_meta && $role_meta->isa('Moose::Meta::Role'))
|| $self->throw_error("Unable to canonicalize the 'handles' option with $handles because its metaclass is not a Moose::Meta::Role", data => $handles);
- return map { $_ => $_ } (
+ return map { $_ => $_ }
+ grep { $_ ne 'meta' } (
$role_meta->get_method_list,
map { $_->name } $role_meta->get_required_method_list,
- );
+ );
}
}
$method_body = $method_to_call
if 'CODE' eq ref($method_to_call);
+ my @curried_arguments;
+
+ ($method_to_call, @curried_arguments) = @$method_to_call
+ if 'ARRAY' eq ref($method_to_call);
+
return $self->delegation_metaclass->new(
name => $handle_name,
package_name => $self->associated_class->name,
attribute => $self,
delegate_to_method => $method_to_call,
+ curried_arguments => \@curried_arguments,
);
}