Move even more code up to parent
[gitmo/Moose.git] / lib / Moose / Meta / Method / Accessor / Native / String / Writer.pm
CommitLineData
e7724627 1package Moose::Meta::Method::Accessor::Native::String::Writer;
2
3use strict;
4use warnings;
5
6our $VERSION = '1.13';
7$VERSION = eval $VERSION;
8our $AUTHORITY = 'cpan:STEVAN';
9
9377e13a 10use base 'Moose::Meta::Method::Accessor::Native::Writer';
e7724627 11
12sub _new_value {'$_[0]'}
13
e7724627 14sub _constraint_must_be_checked {
15 my $self = shift;
16
17 my $attr = $self->associated_attribute;
18
19 return $attr->has_type_constraint
20 && ( $attr->type_constraint->name ne 'Str'
21 || ( $attr->should_coerce && $attr->type_constraint->has_coercion ) );
22}
23
24sub _inline_check_coercion {
25 my ( $self, $value ) = @_;
26
27 my $attr = $self->associated_attribute;
28
29 return ''
30 unless $attr->should_coerce && $attr->type_constraint->has_coercion;
31
32 # We want to break the aliasing in @_ in case the coercion tries to make a
33 # destructive change to an array member.
34 return '@_ = @{ $attr->type_constraint->coerce($value) };';
35}
36
371;