9c97ab31b12789af695b336518d03418ad3c8133
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / String / chomp.pm
1 package Moose::Meta::Method::Accessor::Native::String::chomp;
2
3 use strict;
4 use warnings;
5
6 our $AUTHORITY = 'cpan:STEVAN';
7
8 use Moose::Role;
9
10 with 'Moose::Meta::Method::Accessor::Native::Writer' => {
11     -excludes => [
12         qw(
13             _maximum_arguments
14             _inline_optimized_set_new_value
15             _return_value
16             )
17     ]
18 };
19
20 sub _maximum_arguments { 0 }
21
22 sub _potential_value {
23     my $self = shift;
24     my ($slot_access) = @_;
25
26     return '(do { '
27              . 'my $val = ' . $slot_access . '; '
28              . '@return = chomp $val; '
29              . '$val '
30          . '})';
31 }
32
33 sub _inline_optimized_set_new_value {
34     my $self = shift;
35     my ($inv, $new, $slot_access) = @_;
36
37     return '@return = chomp ' . $slot_access . ';';
38 }
39
40 sub _return_value {
41     my $self = shift;
42     my ($slot_access) = @_;
43
44     return '$return[0]';
45 }
46
47 no Moose::Role;
48
49 1;