From: Moritz Onken Date: Sun, 16 Jan 2011 17:15:32 +0000 (+0100) Subject: Moose 2.0 ready X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-ClassAttribute.git;a=commitdiff_plain;h=619dd6dff1a9cc73aac3a42ce65725c13a7a11f8 Moose 2.0 ready --- diff --git a/lib/MooseX/ClassAttribute/Trait/Attribute.pm b/lib/MooseX/ClassAttribute/Trait/Attribute.pm index 1a85d07..435842d 100644 --- a/lib/MooseX/ClassAttribute/Trait/Attribute.pm +++ b/lib/MooseX/ClassAttribute/Trait/Attribute.pm @@ -119,16 +119,27 @@ around 'clear_value' => sub { ->clear_class_attribute_value( $self->name() ); }; -around 'inline_get' => sub { - shift; +override '_inline_instance_get' => sub { my $self = shift; return $self->associated_class() ->inline_get_class_slot_value( $self->slots() ); }; -around 'inline_set' => sub { - shift; + +override _inline_weaken_value => sub { + my $self = shift; + my ($instance, $value) = @_; + return unless $self->is_weak_ref; + + my $mi = $self->associated_class->get_meta_instance; + return ( + $self->associated_class->inline_weaken_class_slot_value( $self->slots(), $value ), + 'if ref ' . $value . ';', + ); +}; + +override '_inline_instance_set' => sub { my $self = shift; shift; my $value = shift; @@ -137,24 +148,18 @@ around 'inline_set' => sub { my $code = $meta->inline_set_class_slot_value( $self->slots(), $value ) . ";"; - $code - .= $meta->inline_weaken_class_slot_value( $self->slots(), $value ) - . " if ref $value;" - if $self->is_weak_ref(); return $code; }; -around 'inline_has' => sub { - shift; +override '_inline_instance_has' => sub { my $self = shift; return $self->associated_class() ->inline_is_class_slot_initialized( $self->slots() ); }; -around 'inline_clear' => sub { - shift; +override '_inline_clear_value' => sub { my $self = shift; return $self->associated_class()