Beginning of dzilization
[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
44babf1f 6our $AUTHORITY = 'cpan:STEVAN';
7
8b9641b8 8use Moose::Role;
9
7f5ec80d 10with 'Moose::Meta::Method::Accessor::Native::Hash::Writer' => {
11 -excludes => [
12 qw(
a486d5ad 13 _inline_optimized_set_new_value
7f5ec80d 14 _return_value
15 )
16 ],
17};
44babf1f 18
19sub _adds_members { 0 }
20
21sub _potential_value {
53a4677c 22 my $self = shift;
23 my ($slot_access) = @_;
24
25 return '(do { '
26 . 'my %potential = %{ (' . $slot_access . ') }; '
27 . '@return = delete @potential{@_}; '
28 . '\%potential; '
29 . '})';
44babf1f 30}
31
a486d5ad 32sub _inline_optimized_set_new_value {
53a4677c 33 my $self = shift;
34 my ($inv, $new, $slot_access) = @_;
44babf1f 35
a486d5ad 36 return '@return = delete @{ (' . $slot_access . ') }{@_};';
7f5ec80d 37}
38
39sub _return_value {
53a4677c 40 my $self = shift;
41 my ($slot_access) = @_;
7f5ec80d 42
53a4677c 43 return 'wantarray ? @return : $return[-1]';
44babf1f 44}
45
8b9641b8 46no Moose::Role;
47
44babf1f 481;