From: Moritz Onken Date: Wed, 9 Feb 2011 18:01:39 +0000 (+0100) Subject: moose 1.21 and 1.9 compatible X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4241af71f3ad8ea0b8e8ca23e546026c58c9d7da;p=gitmo%2FMooseX-ClassAttribute.git moose 1.21 and 1.9 compatible --- diff --git a/lib/MooseX/ClassAttribute/Trait/Attribute.pm b/lib/MooseX/ClassAttribute/Trait/Attribute.pm index 01b25da..8df03c1 100644 --- a/lib/MooseX/ClassAttribute/Trait/Attribute.pm +++ b/lib/MooseX/ClassAttribute/Trait/Attribute.pm @@ -80,48 +80,64 @@ around 'clear_value' => sub { ->clear_class_attribute_value( $self->name() ); }; -override '_inline_instance_get' => sub { - my $self = shift; + +sub _inline_instance_get {} +sub inline_get {} +around ['inline_get', '_inline_instance_get'] => sub { + my ($orig, $self) = @_; return $self->associated_class() ->inline_get_class_slot_value( $self->slots() ); }; +sub _inline_weaken_value {} +around ['_inline_weaken_value'] => sub { + my ($orig, $self, $instance, $value) = @_; + return '' unless $self->is_weak_ref; + return + $self->associated_class->inline_weaken_class_slot_value( $self->slots() ) + . 'if ref ' . $value . ';'; +}; -override '_inline_weaken_value' => sub { - my $self = shift; - my ($instance, $value) = @_; - return unless $self->is_weak_ref; +sub _inline_instance_set {} +around ['_inline_instance_set'] => sub { + my ($orig, $self, undef, $value) = @_; - my $mi = $self->associated_class->get_meta_instance; - return ( - $self->associated_class->inline_weaken_class_slot_value( $self->slots(), $value ), - 'if ref ' . $value . ';', - ); + my $meta = $self->associated_class(); + + my $code + = $meta->inline_set_class_slot_value( $self->slots(), $value ) . ";"; + + return $code; }; -override '_inline_instance_set' => sub { - my $self = shift; - shift; - my $value = shift; +sub inline_set {} +around ['inline_set'] => sub { + my ($orig, $self, undef, $value) = @_; my $meta = $self->associated_class(); my $code = $meta->inline_set_class_slot_value( $self->slots(), $value ) . ";"; + $code + .= $self->_inline_weaken_value( $self->slots(), $value ); return $code; }; -override '_inline_instance_has' => sub { - my $self = shift; +sub _inline_instance_has {} +sub inline_has {} +around ['inline_has', '_inline_instance_has'] => sub { + my ($orig, $self) = @_; return $self->associated_class() ->inline_is_class_slot_initialized( $self->slots() ); }; -override '_inline_clear_value' => sub { - my $self = shift; +sub _inline_clear_value {} +sub inline_clear {} +around ['inline_clear', '_inline_clear_value'] => sub { + my ($orig, $self) = @_; return $self->associated_class() ->inline_deinitialize_class_slot( $self->slots() );