8efbd79705c0cfef1b52315bb018453971b1d225
[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 use Moose::Role;
7
8 with 'Moose::Meta::Method::Accessor::Native::Writer' => {
9     -excludes => [
10         qw(
11             _maximum_arguments
12             _inline_optimized_set_new_value
13             _return_value
14             )
15     ]
16 };
17
18 sub _maximum_arguments { 0 }
19
20 sub _potential_value {
21     my $self = shift;
22     my ($slot_access) = @_;
23
24     return '(do { '
25              . 'my $val = ' . $slot_access . '; '
26              . '@return = chomp $val; '
27              . '$val '
28          . '})';
29 }
30
31 sub _inline_optimized_set_new_value {
32     my $self = shift;
33     my ($inv, $new, $slot_access) = @_;
34
35     return '@return = chomp ' . $slot_access . ';';
36 }
37
38 sub _return_value {
39     my $self = shift;
40     my ($slot_access) = @_;
41
42     return '$return[0]';
43 }
44
45 no Moose::Role;
46
47 1;