1 package Moose::Meta::Attribute::Native::Trait::String;
4 with 'Moose::Meta::Attribute::Native::Trait';
6 sub _default_default { q{} }
7 sub _default_is { 'rw' }
8 sub _helper_type { 'Str' }
14 # ABSTRACT: Helper trait for Str attributes
32 replace_text => 'replace',
36 my $page = MyHomePage->new();
37 $page->add_text("foo"); # same as $page->text($page->text . "foo");
41 This trait provides native delegation methods for strings.
45 If you don't provide an C<isa> value for your attribute, it will default to
48 =head1 PROVIDED METHODS
54 Increments the value stored in this slot using the magical string autoincrement
55 operator. Note that Perl doesn't provide analogous behavior in C<-->, so
56 C<dec> is not available. This method returns the new value.
58 This method does not accept any arguments.
60 =item * B<append($string)>
62 Appends to the string, like C<.=>, and returns the new value.
64 This method requires a single argument.
66 =item * B<prepend($string)>
68 Prepends to the string and returns the new value.
70 This method requires a single argument.
72 =item * B<replace($pattern, $replacement)>
74 Performs a regexp substitution (L<perlop/s>). There is no way to provide the
75 C<g> flag, but code references will be accepted for the replacement, causing
76 the regex to be modified with a single C<e>. C</smxi> can be applied using the
77 C<qr> operator. This method returns the new value.
79 This method requires two arguments.
81 =item * B<match($pattern)>
83 Runs the regex against the string and returns the matching value(s).
85 This method requires a single argument.
89 Just like L<perlfunc/chop>. This method returns the chopped character.
91 This method does not accept any arguments.
95 Just like L<perlfunc/chomp>. This method returns the number of characters
98 This method does not accept any arguments.
102 Sets the string to the empty string (not the value passed to C<default>).
104 This method does not have a defined return value.
106 This method does not accept any arguments.
110 Just like L<perlfunc/length>, returns the length of the string.
114 This acts just like L<perlfunc/substr>. When called as a writer, it returns
115 the substring that was replaced, just like the Perl builtin.
117 This method requires at least one argument, and accepts no more than three.
123 See L<Moose/BUGS> for details on reporting bugs.