1 package Moose::Meta::Method::Accessor::Native::String::Writer;
7 $VERSION = eval $VERSION;
8 our $AUTHORITY = 'cpan:STEVAN';
10 use base 'Moose::Meta::Method::Accessor::Native::Writer';
12 sub _new_value {'$_[0]'}
14 sub _constraint_must_be_checked {
17 my $attr = $self->associated_attribute;
19 return $attr->has_type_constraint
20 && ( $attr->type_constraint->name ne 'Str'
21 || ( $attr->should_coerce && $attr->type_constraint->has_coercion ) );
24 sub _inline_check_coercion {
25 my ( $self, $value ) = @_;
27 my $attr = $self->associated_attribute;
30 unless $attr->should_coerce && $attr->type_constraint->has_coercion;
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) };';