package MooseX::AttributeHelpers::MethodProvider::String;
use Moose::Role;
-our $VERSION = '0.12_01';
+our $VERSION = '0.23';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-sub append : method {
+sub append : method {
my ($attr, $reader, $writer) = @_;
return sub { $writer->( $_[0], $reader->($_[0]) . $_[1] ) };
}
sub clear : method {
- my ($attr, $reader, $writer ) = @_;
+ my ($attr, $reader, $writer) = @_;
return sub { $writer->( $_[0], '' ) }
}
+sub length : method {
+ my ($attr, $reader, $writer) = @_;
+ return sub {
+ my $v = $reader->($_[0]);
+ return CORE::length($v);
+ };
+}
+
+sub substr : method {
+ my ($attr, $reader, $writer) = @_;
+ return sub {
+ my $self = shift;
+ my $v = $reader->($self);
+
+ my $offset = defined $_[0] ? shift : 0;
+ my $length = defined $_[0] ? shift : CORE::length($v);
+ my $replacement = defined $_[0] ? shift : undef;
+
+ my $ret;
+ if (defined $replacement) {
+ $ret = CORE::substr($v, $offset, $length, $replacement);
+ $writer->($self, $v);
+ }
+ else {
+ $ret = CORE::substr($v, $offset, $length);
+ }
+
+ return $ret;
+ };
+}
+
1;
__END__
=head1 NAME
MooseX::AttributeHelpers::MethodProvider::String
-
+
=head1 DESCRIPTION
-This is a role which provides the method generators for
+This is a role which provides the method generators for
L<MooseX::AttributeHelpers::String>.
=head1 METHODS
=item B<clear>
+=item B<length>
+
+=item B<substr>
+
=back
=head1 BUGS
-All complex software has bugs lurking in it, and this module is no
+All complex software has bugs lurking in it, and this module is no
exception. If you find a bug please either email me, or add the bug
to cpan-RT.
=head1 COPYRIGHT AND LICENSE
-Copyright 2007-2008 by Infinity Interactive, Inc.
+Copyright 2007-2009 by Infinity Interactive, Inc.
L<http://www.iinteractive.com>