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