X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FMethod%2FAccessor%2FNative%2FHash%2Fset.pm;h=3185f32e73a3f8ae2bb4c68ff494ec136f8de548;hb=HEAD;hp=1f2d3d855358c55cc2f9115a56a1b4979570c9a5;hpb=ad46f5244f59757c45306c4a41e195b7aa4b0943;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm b/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm index 1f2d3d8..3185f32 100644 --- a/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm +++ b/lib/Moose/Meta/Method/Accessor/Native/Hash/set.pm @@ -6,23 +6,9 @@ use warnings; use List::MoreUtils (); use Scalar::Util qw( looks_like_number ); -our $AUTHORITY = 'cpan:STEVAN'; - use Moose::Role; -with 'Moose::Meta::Method::Accessor::Native::Hash::Writer' => { - -excludes => [ - qw( - _minimum_arguments - _maximum_arguments - _inline_process_arguments - _inline_check_arguments - _inline_coerce_new_values - _inline_optimized_set_new_value - _return_value - ) - ], -}; +with 'Moose::Meta::Method::Accessor::Native::Hash::Writer'; sub _minimum_arguments { 2 } @@ -36,7 +22,10 @@ around _inline_check_argument_count => sub { $self->$orig(@_), 'if (@_ % 2) {', $self->_inline_throw_error( - '"You must pass an even number of arguments to set"', + sprintf( + '"You must pass an even number of arguments to %s"', + $self->delegate_to_method, + ), ) . ';', '}', ); @@ -58,7 +47,10 @@ sub _inline_check_arguments { 'for (@keys_idx) {', 'if (!defined($_[$_])) {', $self->_inline_throw_error( - '"Hash keys passed to set must be defined"', + sprintf( + '"Hash keys passed to %s must be defined"', + $self->delegate_to_method, + ), ) . ';', '}', '}', @@ -81,7 +73,7 @@ sub _inline_coerce_new_values { 'my $iter = List::MoreUtils::natatime(2, @_);', '@_ = ();', 'while (my ($key, $val) = $iter->()) {', - 'push @_, $key, $member_tc_obj->coerce($val);', + 'push @_, $key, $member_coercion->($val);', '}', ); };