Composite now implemented.
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / String.pm
CommitLineData
190b1c02 1package MooseX::AttributeHelpers::String;
2use Moose;
786dbc3d 3use MooseX::AttributeHelpers::MethodProvider::String;
8683383a 4
5extends 'MooseX::AttributeHelpers::Base';
190b1c02 6
7our $VERSION = '0.01';
8our $AUTHORITY = 'cpan:STEVAN';
9
786dbc3d 10__PACKAGE__->sugar(
8683383a 11 default_options => {
12 is => 'rw',
13 default => '',
14 },
190b1c02 15
8683383a 16 auto_provide => 1,
786dbc3d 17 method_provider => 'String',
8683383a 18 shortcut => 'String',
190b1c02 19);
20
190b1c02 21no Moose;
190b1c02 22
231;
24
25__END__
26
27=pod
28
29=head1 NAME
30
31MooseX::AttributeHelpers::String
32
33=head1 SYNOPSIS
34
35 package MyHomePage;
36 use Moose;
37 use MooseX::AttributeHelpers;
38
39 has 'text' => (
40 metaclass => 'String',
41 is => 'rw',
42 isa => 'Str',
43 default => sub { '' },
44 provides => {
45 append => "add_text",
46 replace => "replace_text",
47 }
48 );
49
50 my $page = MyHomePage->new();
51 $page->add_text("foo"); # same as $page->text($page->text . "foo");
52
53=head1 DESCRIPTION
54
55This module provides a simple string attribute, to which mutating string
56operations can be applied more easily (no need to make an lvalue attribute
57metaclass or use temporary variables). Additional methods are provided for
58completion.
59
60If your attribute definition does not include any of I<is>, I<isa>,
61I<default> or I<provides> but does use the C<String> metaclass,
62then this module applies defaults as in the L</SYNOPSIS>
8683383a 63above. This allows for a very basic attribute definition:
190b1c02 64
65 has 'foo' => (metaclass => 'String');
66 $obj->append_foo;
67
190b1c02 68=head1 PROVIDED METHODS
69
720fa35b 70The methods for this metaclass are provided by
71L<MooseX::AttributeHelpers::MethodProvider::String>.
190b1c02 72
73=head1 BUGS
74
75All complex software has bugs lurking in it, and this module is no
76exception. If you find a bug please either email me, or add the bug
77to cpan-RT.
78
79=head1 AUTHOR
80
81Stevan Little E<lt>stevan@iinteractive.comE<gt>
82
83=head1 COPYRIGHT AND LICENSE
84
99c62fb8 85Copyright 2007-2008 by Infinity Interactive, Inc.
190b1c02 86
87L<http://www.iinteractive.com>
88
89This library is free software; you can redistribute it and/or modify
90it under the same terms as Perl itself.
91
92=cut