bump version
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / Trait / String.pm
index dc0f9fa..8be88f3 100644 (file)
@@ -1,21 +1,23 @@
 package Moose::Meta::Attribute::Native::Trait::String;
 use Moose::Role;
 
-our $VERSION   = '1.06';
+our $VERSION   = '1.23';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
-use Moose::Meta::Attribute::Native::MethodProvider::String;
+use Moose::Meta::Method::Accessor::Native::String::append;
+use Moose::Meta::Method::Accessor::Native::String::chomp;
+use Moose::Meta::Method::Accessor::Native::String::chop;
+use Moose::Meta::Method::Accessor::Native::String::clear;
+use Moose::Meta::Method::Accessor::Native::String::inc;
+use Moose::Meta::Method::Accessor::Native::String::length;
+use Moose::Meta::Method::Accessor::Native::String::match;
+use Moose::Meta::Method::Accessor::Native::String::prepend;
+use Moose::Meta::Method::Accessor::Native::String::replace;
+use Moose::Meta::Method::Accessor::Native::String::substr;
 
 with 'Moose::Meta::Attribute::Native::Trait';
 
-has 'method_provider' => (
-    is        => 'ro',
-    isa       => 'ClassName',
-    predicate => 'has_method_provider',
-    default   => 'Moose::Meta::Attribute::Native::MethodProvider::String',
-);
-
 sub _default_default { q{} }
 sub _default_is { 'rw' }
 sub _helper_type { 'Str' }
@@ -38,100 +40,98 @@ Moose::Meta::Attribute::Native::Trait::String - Helper trait for Str attributes
   use Moose;
 
   has 'text' => (
-      traits    => ['String'],
-      is        => 'rw',
-      isa       => 'Str',
-      default   => q{},
-      handles   => {
+      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");
+  $page->add_text("foo");    # same as $page->text($page->text . "foo");
 
 =head1 DESCRIPTION
 
-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.
+This trait provides native delegation methods for strings.
 
-If your attribute definition does not include any of I<is>, I<isa>,
-I<default> or I<handles> but does use the C<String> metaclass,
-then this module applies defaults as in the L</SYNOPSIS>
-above. This allows for a very basic string definition:
+=head1 DEFAULT TYPE
 
-  has 'foo' => (traits => ['String']);
-  $obj->append_foo;
+If you don't provide an C<isa> value for your attribute, it will default to
+C<Str>.
 
 =head1 PROVIDED METHODS
 
-These methods are implemented in
-L<Moose::Meta::Attribute::Native::MethodProvider::String>. It is important to
-note that all those methods do in place modification of the value stored in
-the attribute.
-
 =over 4
 
-=item B<inc>
+=item * B<inc>
 
 Increments the value stored in this slot using the magical string autoincrement
 operator. Note that Perl doesn't provide analogous behavior in C<-->, so
-C<dec> is not available.
+C<dec> is not available. This method returns the new value.
+
+This method does not accept any arguments.
+
+=item * B<append($string)>
+
+Appends to the string, like C<.=>, and returns the new value.
 
-=item B<append($string)>
+This method requires a single argument.
 
-Append a string, like C<.=>.
+=item * B<prepend($string)>
 
-=item B<prepend($string)>
+Prepends to the string and returns the new value.
 
-Prepend a string.
+This method requires a single argument.
 
-=item B<replace($pattern, $replacement)>
+=item * B<replace($pattern, $replacement)>
 
 Performs a regexp substitution (L<perlop/s>). There is no way to provide the
 C<g> flag, but code references will be accepted for the replacement, causing
 the regex to be modified with a single C<e>. C</smxi> can be applied using the
-C<qr> operator.
+C<qr> operator. This method returns the new value.
 
-=item B<match($pattern)>
+This method requires two arguments.
 
-Like C<replace> but without the replacement. Provided mostly for completeness.
+=item * B<match($pattern)>
 
-=item B<chop>
+Runs the regex against the string and returns the matching value(s).
 
-L<perlfunc/chop>
+This method requires a single argument.
 
-=item B<chomp>
+=item * B<chop>
 
-L<perlfunc/chomp>
+Just like L<perlfunc/chop>. This method returns the chopped character.
 
-=item B<clear>
+This method does not accept any arguments.
 
-Sets the string to the empty string (not the value passed to C<default>).
+=item * B<chomp>
 
-=item B<length>
+Just like L<perlfunc/chomp>. This method returns the number of characters
+removed.
 
-L<perlfunc/length>
+This method does not accept any arguments.
 
-=item B<substr>
+=item * B<clear>
 
-L<perlfunc/substr>. We go to some lengths to match the different functionality
-based on C<substr>'s arity.
+Sets the string to the empty string (not the value passed to C<default>).
 
-=back
+This method does not have a defined return value.
 
-=head1 METHODS
+This method does not accept any arguments.
 
-=over 4
+=item * B<length>
+
+Just like L<perlfunc/length>, returns the length of the string.
 
-=item B<meta>
+=item * B<substr>
 
-=item B<method_provider>
+This acts just like L<perlfunc/substr>. When called as a writer, it returns
+the substring that was replaced, just like the Perl builtin.
 
-=item B<has_method_provider>
+This method requires at least one argument, and accepts no more than three.
 
 =back
 
@@ -145,7 +145,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2007-2009 by Infinity Interactive, Inc.
+Copyright 2007-2010 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>