Commit | Line | Data |
---|---|---|
44babf1f | 1 | package Moose::Meta::Method::Accessor::Native::Hash::delete; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
8b9641b8 | 6 | use Moose::Role; |
7 | ||
7f5ec80d | 8 | with '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 | |
17 | sub _adds_members { 0 } | |
18 | ||
19 | sub _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 | 30 | sub _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 | ||
37 | sub _return_value { | |
53a4677c | 38 | my $self = shift; |
39 | my ($slot_access) = @_; | |
7f5ec80d | 40 | |
53a4677c | 41 | return 'wantarray ? @return : $return[-1]'; |
44babf1f | 42 | } |
43 | ||
8b9641b8 | 44 | no Moose::Role; |
45 | ||
44babf1f | 46 | 1; |