X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FClassAttribute%2FTrait%2FAttribute.pm;fp=lib%2FMooseX%2FClassAttribute%2FTrait%2FAttribute.pm;h=4d3f80d635a94e751b9385af4fc60c2ceb2a6602;hb=28c238080ac8d1824ffb29fd20eca5550a49b182;hp=ecfbf0fc79ed5e17cac9ee88f894e95471a9eb0c;hpb=9e2d0ef139ad6e5c299561989e36ecdbba3843fb;p=gitmo%2FMooseX-ClassAttribute.git diff --git a/lib/MooseX/ClassAttribute/Trait/Attribute.pm b/lib/MooseX/ClassAttribute/Trait/Attribute.pm index ecfbf0f..4d3f80d 100644 --- a/lib/MooseX/ClassAttribute/Trait/Attribute.pm +++ b/lib/MooseX/ClassAttribute/Trait/Attribute.pm @@ -119,47 +119,101 @@ around clear_value => sub { ->clear_class_attribute_value( $self->name() ); }; -around inline_get => sub { - shift; - my $self = shift; - - return $self->associated_class() - ->inline_get_class_slot_value( $self->slots() ); -}; - -around inline_set => sub { - shift; - my $self = shift; - shift; - my $value = shift; - - my $meta = $self->associated_class(); - - 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; - my $self = shift; - - return $self->associated_class() - ->inline_is_class_slot_initialized( $self->slots() ); -}; - -around inline_clear => sub { - shift; - my $self = shift; - - return $self->associated_class() - ->inline_deinitialize_class_slot( $self->slots() ); -}; +if ( $Moose::VERSION < 1.99 ) { + around inline_get => sub { + shift; + my $self = shift; + + return $self->associated_class() + ->inline_get_class_slot_value( $self->slots() ); + }; + + around inline_set => sub { + shift; + my $self = shift; + shift; + my $value = shift; + + my $meta = $self->associated_class(); + + 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; + my $self = shift; + + return $self->associated_class() + ->inline_is_class_slot_initialized( $self->slots() ); + }; + + around inline_clear => sub { + shift; + my $self = shift; + + return $self->associated_class() + ->inline_deinitialize_class_slot( $self->slots() ); + }; +} +else { + around _inline_instance_get => sub { + shift; + my $self = shift; + + return $self->associated_class() + ->inline_get_class_slot_value( $self->slots() ); + }; + + around _inline_instance_set => sub { + shift; + my $self = shift; + shift; + my $value = shift; + + return $self->associated_class() + ->inline_set_class_slot_value( $self->slots(), $value ); + }; + + around _inline_instance_has => sub { + shift; + my $self = shift; + + return $self->associated_class() + ->inline_is_class_slot_initialized( $self->slots() ); + }; + + around _inline_instance_clear => sub { + shift; + my $self = shift; + + return $self->associated_class() + ->inline_deinitialize_class_slot( $self->slots() ); + }; + + around _inline_weaken_value => sub { + shift; + my $self = shift; + shift; + my $value = shift; + + return unless $self->is_weak_ref(); + + return ( + $self->associated_class->inline_weaken_class_slot_value( + $self->slots(), $value + ), + 'if ref ' . $value . ';', + ); + }; +} 1;