1 package Moose::Meta::Method::Accessor::Native::String::replace;
9 our $VERSION = '1.9900';
10 $VERSION = eval $VERSION;
11 our $AUTHORITY = 'cpan:STEVAN';
15 with 'Moose::Meta::Method::Accessor::Native::Writer' => {
20 _inline_check_arguments
21 _inline_optimized_set_new_value
26 sub _minimum_arguments { 1 }
28 sub _maximum_arguments { 2 }
30 sub _inline_check_arguments {
34 'if (!Moose::Util::_STRINGLIKE0($_[0]) && !Params::Util::_REGEX($_[0])) {',
35 $self->_inline_throw_error(
36 '"The first argument passed to replace must be a string or '
40 'if (!Moose::Util::_STRINGLIKE0($_[1]) && !Params::Util::_CODELIKE($_[1])) {',
41 $self->_inline_throw_error(
42 '"The second argument passed to replace must be a string or '
49 sub _potential_value {
51 my ($slot_access) = @_;
54 . 'my $val = ' . $slot_access . '; '
56 . '? $val =~ s/$_[0]/$_[1]->()/e '
57 . ': $val =~ s/$_[0]/$_[1]/; '
62 sub _inline_optimized_set_new_value {
64 my ($inv, $new, $slot_access) = @_;
68 '? ' . $slot_access . ' =~ s/$_[0]/$_[1]->()/e',
69 ': ' . $slot_access . ' =~ s/$_[0]/$_[1]/;',