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