X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FAccessor%2FNative%2FCollection.pm;h=de38c8ddfda04d530e86cc540e6972853ea3711a;hb=5394a1c721689ae6c3168a22dd92a0499e8d9744;hp=45b2340ae3080576e9d82490d93bc0ce01ce1e67;hpb=d67398abd3303d2fb8ed67d78313a202dec7283b;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Accessor/Native/Collection.pm b/lib/Moose/Meta/Method/Accessor/Native/Collection.pm index 45b2340..de38c8d 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Collection.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Collection.pm @@ -3,19 +3,23 @@ package Moose::Meta::Method::Accessor::Native::Collection; use strict; use warnings; -our $VERSION = '1.14'; +our $VERSION = '1.15'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; -sub _value_needs_copy { +use Moose::Role; + +requires qw( _adds_members ); + +around _value_needs_copy => sub { shift; my $self = shift; return $self->_constraint_must_be_checked && !$self->_check_new_members_only; -} +}; -sub _inline_tc_code { +around _inline_tc_code => sub { shift; my ( $self, $potential_value ) = @_; @@ -30,7 +34,7 @@ sub _inline_tc_code { return $self->_inline_check_coercion($potential_value) . "\n" . $self->_inline_check_constraint($potential_value); } -} +}; sub _check_new_members_only { my $self = shift; @@ -70,16 +74,16 @@ sub _inline_check_member_constraint { ) . " for $new_value;"; } -sub _inline_check_constraint { +around _inline_check_constraint => sub { my $orig = shift; my $self = shift; return q{} unless $self->_constraint_must_be_checked; return $self->$orig( $_[0] ); -} +}; -sub _inline_get_old_value_for_trigger { +around _inline_get_old_value_for_trigger => sub { shift; my ( $self, $instance ) = @_; @@ -91,9 +95,9 @@ sub _inline_get_old_value_for_trigger { . $self->_inline_has($instance) . q{ ? } . $self->_inline_copy_old_value( $self->_inline_get($instance) ) . ": ();\n"; -} +}; -sub _eval_environment { +around _eval_environment => sub { my $orig = shift; my $self = shift; @@ -108,7 +112,7 @@ sub _eval_environment { ->_compiled_type_constraint ); return $env; -} +}; no Moose::Role;