From: Dave Rolsky Date: Tue, 9 Feb 2010 23:10:10 +0000 (-0600) Subject: Use namespace::autoclean and tidy code X-Git-Tag: 0.11~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=67e6eaa5fa77cffa4d1d7fb6c56c62470eddcd3e;p=gitmo%2FMooseX-ClassAttribute.git Use namespace::autoclean and tidy code --- diff --git a/lib/MooseX/ClassAttribute/Meta/Method/Accessor.pm b/lib/MooseX/ClassAttribute/Meta/Method/Accessor.pm index f028970..3902ae1 100644 --- a/lib/MooseX/ClassAttribute/Meta/Method/Accessor.pm +++ b/lib/MooseX/ClassAttribute/Meta/Method/Accessor.pm @@ -3,43 +3,40 @@ package MooseX::ClassAttribute::Meta::Method::Accessor; use strict; use warnings; +use namespace::autoclean; use Moose; extends 'Moose::Meta::Method::Accessor'; +sub _generate_predicate_method_inline { + my $attr = (shift)->associated_attribute; -sub _generate_predicate_method_inline -{ - my $attr = (shift)->associated_attribute; - - my $code = - eval 'sub {' - . $attr->associated_class()->inline_is_class_slot_initialized( $attr->name() ) - . '}'; + my $code + = eval 'sub {' + . $attr->associated_class() + ->inline_is_class_slot_initialized( $attr->name() ) . '}'; confess "Could not generate inline predicate because : $@" if $@; return $code; } -sub _generate_clearer_method_inline -{ +sub _generate_clearer_method_inline { my $attr = (shift)->associated_attribute; my $meta_instance = $attr->associated_class->instance_metaclass; - my $code = - eval 'sub {' - . $attr->associated_class()->inline_deinitialize_class_slot( $attr->name() ) - . '}'; + my $code + = eval 'sub {' + . $attr->associated_class() + ->inline_deinitialize_class_slot( $attr->name() ) . '}'; confess "Could not generate inline clearer because : $@" if $@; return $code; } -sub _inline_store -{ - my $self = shift; +sub _inline_store { + my $self = shift; shift; my $value = shift; @@ -47,16 +44,18 @@ sub _inline_store my $meta = $attr->associated_class(); - my $code = $meta->inline_set_class_slot_value( $attr->slots(), $value ) . ";"; - $code .= $meta->inline_weaken_class_slot_value( $attr->slots(), $value ) . ";" + my $code + = $meta->inline_set_class_slot_value( $attr->slots(), $value ) . ";"; + $code + .= $meta->inline_weaken_class_slot_value( $attr->slots(), $value ) + . ";" if $attr->is_weak_ref(); return $code; } -sub _inline_get -{ - my $self = shift; +sub _inline_get { + my $self = shift; my $attr = $self->associated_attribute; my $meta = $attr->associated_class(); @@ -64,9 +63,8 @@ sub _inline_get return $meta->inline_get_class_slot_value( $attr->slots() ); } -sub _inline_access -{ - my $self = shift; +sub _inline_access { + my $self = shift; my $attr = $self->associated_attribute; my $meta = $attr->associated_class(); @@ -74,8 +72,7 @@ sub _inline_access return $meta->inline_class_slot_access( $attr->slots() ); } -sub _inline_has -{ +sub _inline_has { my $self = shift; my $attr = $self->associated_attribute; @@ -84,41 +81,37 @@ sub _inline_has return $meta->inline_is_class_slot_initialized( $attr->slots() ); } -sub _inline_init_slot -{ +sub _inline_init_slot { my $self = shift; return $self->_inline_store( undef, $_[-1] ); } -sub _inline_check_lazy -{ +sub _inline_check_lazy { my $self = shift; - return - $self->SUPER::_inline_check_lazy - ( q{'} . $self->associated_attribute()->associated_class()->name() . q{'} ); + return $self->SUPER::_inline_check_lazy( q{'} + . $self->associated_attribute()->associated_class()->name() + . q{'} ); } -sub _inline_get_old_value_for_trigger -{ +sub _inline_get_old_value_for_trigger { my $self = shift; my $attr = $self->associated_attribute(); return '' unless $attr->has_trigger(); - my $pred = - $attr->associated_class()->inline_is_class_slot_initialized( $attr->name() ); + my $pred = $attr->associated_class() + ->inline_is_class_slot_initialized( $attr->name() ); return - 'my @old = ' + 'my @old = ' . $pred . q{ ? } - . $self->_inline_get() . q{ : ()} . ";\n"; + . $self->_inline_get() + . q{ : ()} . ";\n"; } -no Moose; - 1; =pod