1 package Moose::Meta::Attribute::Native::Trait::String;
4 our $VERSION = '1.9900';
5 $VERSION = eval $VERSION;
6 our $AUTHORITY = 'cpan:STEVAN';
8 with 'Moose::Meta::Attribute::Native::Trait';
10 sub _default_default { q{} }
11 sub _default_is { 'rw' }
12 sub _helper_type { 'Str' }
24 Moose::Meta::Attribute::Native::Trait::String - Helper trait for Str attributes
38 replace_text => 'replace',
42 my $page = MyHomePage->new();
43 $page->add_text("foo"); # same as $page->text($page->text . "foo");
47 This trait provides native delegation methods for strings.
51 If you don't provide an C<isa> value for your attribute, it will default to
54 =head1 PROVIDED METHODS
60 Increments the value stored in this slot using the magical string autoincrement
61 operator. Note that Perl doesn't provide analogous behavior in C<-->, so
62 C<dec> is not available. This method returns the new value.
64 This method does not accept any arguments.
66 =item * B<append($string)>
68 Appends to the string, like C<.=>, and returns the new value.
70 This method requires a single argument.
72 =item * B<prepend($string)>
74 Prepends to the string and returns the new value.
76 This method requires a single argument.
78 =item * B<replace($pattern, $replacement)>
80 Performs a regexp substitution (L<perlop/s>). There is no way to provide the
81 C<g> flag, but code references will be accepted for the replacement, causing
82 the regex to be modified with a single C<e>. C</smxi> can be applied using the
83 C<qr> operator. This method returns the new value.
85 This method requires two arguments.
87 =item * B<match($pattern)>
89 Runs the regex against the string and returns the matching value(s).
91 This method requires a single argument.
95 Just like L<perlfunc/chop>. This method returns the chopped character.
97 This method does not accept any arguments.
101 Just like L<perlfunc/chomp>. This method returns the number of characters
104 This method does not accept any arguments.
108 Sets the string to the empty string (not the value passed to C<default>).
110 This method does not have a defined return value.
112 This method does not accept any arguments.
116 Just like L<perlfunc/length>, returns the length of the string.
120 This acts just like L<perlfunc/substr>. When called as a writer, it returns
121 the substring that was replaced, just like the Perl builtin.
123 This method requires at least one argument, and accepts no more than three.
129 See L<Moose/BUGS> for details on reporting bugs.
133 Stevan Little E<lt>stevan@iinteractive.comE<gt>
135 =head1 COPYRIGHT AND LICENSE
137 Copyright 2007-2009 by Infinity Interactive, Inc.
139 L<http://www.iinteractive.com>
141 This library is free software; you can redistribute it and/or modify
142 it under the same terms as Perl itself.