1 package Moose::Meta::Method::Accessor::Native::String::replace;
11 with 'Moose::Meta::Method::Accessor::Native::Writer' => {
16 _inline_check_arguments
17 _inline_optimized_set_new_value
22 sub _minimum_arguments { 1 }
24 sub _maximum_arguments { 2 }
26 sub _inline_check_arguments {
30 'if (!Moose::Util::_STRINGLIKE0($_[0]) && !Params::Util::_REGEX($_[0])) {',
31 $self->_inline_throw_error(
32 '"The first argument passed to replace must be a string or '
36 'if (!Moose::Util::_STRINGLIKE0($_[1]) && !Params::Util::_CODELIKE($_[1])) {',
37 $self->_inline_throw_error(
38 '"The second argument passed to replace must be a string or '
45 sub _potential_value {
47 my ($slot_access) = @_;
50 . 'my $val = ' . $slot_access . '; '
52 . '? $val =~ s/$_[0]/$_[1]->()/e '
53 . ': $val =~ s/$_[0]/$_[1]/; '
58 sub _inline_optimized_set_new_value {
60 my ($inv, $new, $slot_access) = @_;
64 '? ' . $slot_access . ' =~ s/$_[0]/$_[1]->()/e',
65 ': ' . $slot_access . ' =~ s/$_[0]/$_[1]/;',