Use dzil Authority plugin - remove $AUTHORITY from code
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / Hash / delete.pm
CommitLineData
44babf1f 1package Moose::Meta::Method::Accessor::Native::Hash::delete;
2
3use strict;
4use warnings;
5
8b9641b8 6use Moose::Role;
7
7f5ec80d 8with 'Moose::Meta::Method::Accessor::Native::Hash::Writer' => {
9 -excludes => [
10 qw(
a486d5ad 11 _inline_optimized_set_new_value
7f5ec80d 12 _return_value
13 )
14 ],
15};
44babf1f 16
17sub _adds_members { 0 }
18
19sub _potential_value {
53a4677c 20 my $self = shift;
21 my ($slot_access) = @_;
22
23 return '(do { '
24 . 'my %potential = %{ (' . $slot_access . ') }; '
25 . '@return = delete @potential{@_}; '
26 . '\%potential; '
27 . '})';
44babf1f 28}
29
a486d5ad 30sub _inline_optimized_set_new_value {
53a4677c 31 my $self = shift;
32 my ($inv, $new, $slot_access) = @_;
44babf1f 33
a486d5ad 34 return '@return = delete @{ (' . $slot_access . ') }{@_};';
7f5ec80d 35}
36
37sub _return_value {
53a4677c 38 my $self = shift;
39 my ($slot_access) = @_;
7f5ec80d 40
53a4677c 41 return 'wantarray ? @return : $return[-1]';
44babf1f 42}
43
8b9641b8 44no Moose::Role;
45
44babf1f 461;