| MouseX::NativeTraits::Str(3pm) | User Contributed Perl Documentation | MouseX::NativeTraits::Str(3pm) |
MouseX::NativeTraits::Str - Helper trait for Str attributes
package MyHomePage;
use Mouse;
has 'text' => (
traits => ['String'],
is => 'rw',
isa => 'Str',
default => q{},
handles => {
add_text => 'append',
replace_text => 'replace',
},
);
my $page = MyHomePage->new();
$page->add_text("foo"); # same as $page->text($page->text . "foo");
This module provides a simple string attribute, to which mutating string operations can be applied more easily (no need to make an lvalue attribute metaclass or use temporary variables). Additional methods are provided for completion.
These methods are implemented in MouseX::NativeTraits::MethodProvider::Str. It is important to note that all those methods do in place modification of the value stored in the attribute.
MouseX::NativeTraits
| 2022-06-16 | perl v5.34.0 |