$instance->{$slot_name} = $value;
}
+sub set_weak_slot_value {
+ my ( $self, $instance, $slot_name, $value) = @_;
+ $self->set_slot_value( $instance, $slot_name, $value );
+ $self->weeaken_slot_value( $instance, $slot_name );
+}
+
+sub weaken_slot_value {
+ my ( $self, $instance, $slot_name ) = @_;
+ weaken( $instance->{$slot_name} );
+}
+
# convenience method
# non autovivifying stores will have this as { initialize_slot unless slot_initlized; set_slot_value }
sub set_slot_value_with_init {
sub inline_set_slot_value {
my ($self, $instance, $slot_name, $value) = @_;
- $self->_inline_slot_lvalue . " = $value",
+ $self->_inline_slot_lvalue( $instance, $slot_name ) . " = $value",
+}
+
+sub inline_set_weak_slot_value {
+ my ( $self, $instance, $slot_name, $value ) = @_;
+ return ""
+ . $self->inline_set_slot_value( $instance, $slot_name, $value )
+ . "; "
+ . $self->inline_weaken_slot_value( $instance, $slot_name );
+}
+
+sub inline_weaken_slot_value {
+ my ( $self, $instance, $slot_name ) = @_;
+ return 'Scalar::Util::weaken( ' . $self->_inline_slot_lvalue( $instance, $slot_name ) . ')';
}
sub inline_set_slot_value_with_init {
sub _inline_slot_lvalue {
my ($self, $instance, $slot_name) = @_;
- $self->inline_slot_value;
+ $self->inline_get_slot_value( $instance, $slot_name );
}
1;
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
-=cut
\ No newline at end of file
+=cut