1 package Moose::Meta::Attribute::Native::Trait::String;
5 $VERSION = eval $VERSION;
6 our $AUTHORITY = 'cpan:STEVAN';
8 use Moose::Meta::Method::Accessor::Native::String::append;
9 use Moose::Meta::Method::Accessor::Native::String::chomp;
10 use Moose::Meta::Method::Accessor::Native::String::chop;
11 use Moose::Meta::Method::Accessor::Native::String::clear;
12 use Moose::Meta::Method::Accessor::Native::String::inc;
13 use Moose::Meta::Method::Accessor::Native::String::length;
14 use Moose::Meta::Method::Accessor::Native::String::match;
15 use Moose::Meta::Method::Accessor::Native::String::prepend;
16 use Moose::Meta::Method::Accessor::Native::String::replace;
17 use Moose::Meta::Method::Accessor::Native::String::substr;
19 with 'Moose::Meta::Attribute::Native::Trait';
21 sub _default_default { q{} }
22 sub _default_is { 'rw' }
23 sub _helper_type { 'Str' }
35 Moose::Meta::Attribute::Native::Trait::String - Helper trait for Str attributes
49 replace_text => 'replace',
53 my $page = MyHomePage->new();
54 $page->add_text("foo"); # same as $page->text($page->text . "foo");
58 This trait provides native delegation methods for strings.
62 If you don't provide an C<isa> value for your attribute, it will default to
65 =head1 PROVIDED METHODS
71 Increments the value stored in this slot using the magical string autoincrement
72 operator. Note that Perl doesn't provide analogous behavior in C<-->, so
73 C<dec> is not available. This method returns the new value.
75 This method does not accept any arguments.
77 =item * B<append($string)>
79 Appends to the string, like C<.=>, and returns the new value.
81 This method requires a single argument.
83 =item * B<prepend($string)>
85 Prepends to the string and returns the new value.
87 This method requires a single argument.
89 =item * B<replace($pattern, $replacement)>
91 Performs a regexp substitution (L<perlop/s>). There is no way to provide the
92 C<g> flag, but code references will be accepted for the replacement, causing
93 the regex to be modified with a single C<e>. C</smxi> can be applied using the
94 C<qr> operator. This method returns the new value.
96 This method requires two arguments.
98 =item * B<match($pattern)>
100 Runs the regex against the string and returns the matching value(s).
102 This method requires a single argument.
106 Just like L<perlfunc/chop>. This method returns the chopped character.
108 This method does not accept any arguments.
112 Just like L<perlfunc/chomp>. This method returns the number of characters
115 This method does not accept any arguments.
119 Sets the string to the empty string (not the value passed to C<default>).
121 This method does not have a defined return value.
123 This method does not accept any arguments.
127 Just like L<perlfunc/length>, returns the length of the string.
131 This acts just like L<perlfunc/substr>. When called as a writer, it returns
132 the substring that was replaced, just like the Perl builtin.
134 This method requires at least one argument, and accepts no more than three.
140 See L<Moose/BUGS> for details on reporting bugs.
144 Stevan Little E<lt>stevan@iinteractive.comE<gt>
146 =head1 COPYRIGHT AND LICENSE
148 Copyright 2007-2009 by Infinity Interactive, Inc.
150 L<http://www.iinteractive.com>
152 This library is free software; you can redistribute it and/or modify
153 it under the same terms as Perl itself.