X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FAttribute.pm;h=d0cf23477fb3303c46e2485343b544e59b7d4c1b;hb=53362bcb1b32d87630190fbf50679dc37bb51adf;hp=4696e82b8411c7658f34351beccfdfe0f5951131;hpb=8343d5018a33fdbd5b727e99d009f06ec54f10b9;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Attribute.pm b/lib/Class/MOP/Attribute.pm index 4696e82..d0cf234 100644 --- a/lib/Class/MOP/Attribute.pm +++ b/lib/Class/MOP/Attribute.pm @@ -10,7 +10,7 @@ use Carp 'confess'; use Scalar::Util 'blessed', 'weaken'; use Try::Tiny; -our $VERSION = '1.04'; +our $VERSION = '1.11'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -158,9 +158,6 @@ sub _set_initial_slot_value { $instance->$initializer($value, $callback, $self); } -sub associated_class { $_[0]->{'associated_class'} } -sub associated_methods { $_[0]->{'associated_methods'} } - sub get_read_method { my $self = shift; my $reader = $self->reader || $self->accessor; @@ -404,6 +401,40 @@ sub install_accessors { } +sub inline_get { + my $self = shift; + my ($instance) = @_; + + return $self->associated_class->get_meta_instance->inline_get_slot_value( + $instance, $self->name ); +} + +sub inline_set { + my $self = shift; + my ( $instance, $value ) = @_; + + return $self->associated_class->get_meta_instance->inline_set_slot_value( + $instance, $self->name, $value ); +} + +sub inline_has { + my $self = shift; + my ($instance) = @_; + + return + $self->associated_class->get_meta_instance + ->inline_is_slot_initialized( $instance, $self->name ); +} + +sub inline_clear { + my $self = shift; + my ($instance) = @_; + + return + $self->associated_class->get_meta_instance + ->inline_deinitialize_slot( $instance, $self->name ); +} + 1; __END__ @@ -894,6 +925,18 @@ attribute. This does not currently remove methods from the list returned by C. +=item B<< $attr->inline_get >> + +=item B<< $attr->inline_set >> + +=item B<< $attr->inline_has >> + +=item B<< $attr->inline_clear >> + +These methods return a code snippet suitable for inlining the relevant +operation. They expect strings containing variable names to be used in the +inlining, like C<'$self'> or C<'$_[1]'>. + =back =head2 Introspection