Commit | Line | Data |
---|---|---|
e7724627 | 1 | package Moose::Meta::Method::Accessor::Native::String::chop; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
245478d5 | 6 | our $VERSION = '1.19'; |
e7724627 | 7 | $VERSION = eval $VERSION; |
8 | our $AUTHORITY = 'cpan:STEVAN'; | |
9 | ||
8b9641b8 | 10 | use Moose::Role; |
11 | ||
12 | with 'Moose::Meta::Method::Accessor::Native::Writer' => { | |
13 | -excludes => [ | |
14 | qw( | |
15 | _maximum_arguments | |
53a4677c | 16 | _optimized_set_new_value |
7f5ec80d | 17 | _return_value |
8b9641b8 | 18 | ) |
19 | ] | |
20 | }; | |
e7724627 | 21 | |
e7724627 | 22 | sub _maximum_arguments { 0 } |
23 | ||
24 | sub _potential_value { | |
53a4677c | 25 | my $self = shift; |
26 | my ($slot_access) = @_; | |
27 | ||
28 | return '(do { ' | |
29 | . 'my $val = ' . $slot_access . '; ' | |
30 | . '@return = chop $val; ' | |
31 | . '$val; ' | |
32 | . '})'; | |
e7724627 | 33 | } |
34 | ||
53a4677c | 35 | sub _optimized_set_new_value { |
36 | my $self = shift; | |
37 | my ($inv, $new, $slot_access) = @_; | |
e7724627 | 38 | |
53a4677c | 39 | return '@return = chop ' . $slot_access; |
7f5ec80d | 40 | } |
41 | ||
42 | sub _return_value { | |
53a4677c | 43 | my $self = shift; |
44 | my ($slot_access) = @_; | |
7f5ec80d | 45 | |
46 | return '$return[0]'; | |
e7724627 | 47 | } |
48 | ||
8b9641b8 | 49 | no Moose::Role; |
50 | ||
e7724627 | 51 | 1; |