1 package Moose::Meta::Method::Accessor::Native::String::replace;
11 with 'Moose::Meta::Method::Accessor::Native::Writer';
13 sub _minimum_arguments { 1 }
15 sub _maximum_arguments { 2 }
17 sub _inline_check_arguments {
21 'if (!Moose::Util::_STRINGLIKE0($_[0]) && !Params::Util::_REGEX($_[0])) {',
22 $self->_inline_throw_error(
23 '"The first argument passed to replace must be a string or '
27 'if (!Moose::Util::_STRINGLIKE0($_[1]) && !Params::Util::_CODELIKE($_[1])) {',
28 $self->_inline_throw_error(
29 '"The second argument passed to replace must be a string or '
36 sub _potential_value {
38 my ($slot_access) = @_;
41 . 'my $val = ' . $slot_access . '; '
43 . '? $val =~ s/$_[0]/$_[1]->()/e '
44 . ': $val =~ s/$_[0]/$_[1]/; '
49 sub _inline_optimized_set_new_value {
51 my ($inv, $new, $slot_access) = @_;
55 '? ' . $slot_access . ' =~ s/$_[0]/$_[1]->()/e',
56 ': ' . $slot_access . ' =~ s/$_[0]/$_[1]/;',