1MooseX::AttributeHelperUss:e:rTrCaointt:r:iSbturtieMndogo(Ps3ee)rXl::DAotcturmiebnuttaetHieolnpers::Trait::String(3)
2
3
4
6 MooseX::AttributeHelpers::String
7
9 package MyHomePage;
10 use Moose;
11 use MooseX::AttributeHelpers;
12
13 has 'text' => (
14 metaclass => 'String',
15 is => 'rw',
16 isa => 'Str',
17 default => sub { '' },
18 provides => {
19 append => "add_text",
20 replace => "replace_text",
21 }
22 );
23
24 my $page = MyHomePage->new();
25 $page->add_text("foo"); # same as $page->text($page->text . "foo");
26
28 This module provides a simple string attribute, to which mutating
29 string operations can be applied more easily (no need to make an lvalue
30 attribute metaclass or use temporary variables). Additional methods are
31 provided for completion.
32
33 If your attribute definition does not include any of is, isa, default
34 or provides but does use the "String" metaclass, then this module
35 applies defaults as in the "SYNOPSIS" above. This allows for a very
36 basic counter definition:
37
38 has 'foo' => (metaclass => 'String');
39 $obj->append_foo;
40
42 meta
43 method_provider
44 has_method_provider
45 helper_type
46 process_options_for_provides
47 Run before its superclass method.
48
49 check_provides_values
50 Run after its superclass method.
51
53 It is important to note that all those methods do in place modification
54 of the value stored in the attribute.
55
56 inc Increments the value stored in this slot using the magical string
57 autoincrement operator. Note that Perl doesn't provide analogeous
58 behavior in "--", so "dec" is not available.
59
60 append $string
61 Append a string, like ".=".
62
63 prepend $string
64 Prepend a string.
65
66 replace $pattern $replacement
67 Performs a regexp substitution ("s" in perlop). There is no way to
68 provide the "g" flag, but code references will be accepted for the
69 replacement, causing the regex to be modified with a single "e".
70 "/smxi" can be applied using the "qr" operator.
71
72 match $pattern
73 Like replace but without the replacement. Provided mostly for
74 completeness.
75
76 "chop"
77 "chop" in perlfunc
78
79 "chomp"
80 "chomp" in perlfunc
81
82 "clear"
83 Sets the string to the empty string (not the value passed to
84 "default").
85
87 All complex software has bugs lurking in it, and this module is no
88 exception. If you find a bug please either email me, or add the bug to
89 cpan-RT.
90
92 Stevan Little <stevan@iinteractive.com>
93
95 Copyright 2007-2009 by Infinity Interactive, Inc.
96
97 <http://www.iinteractive.com>
98
99 This library is free software; you can redistribute it and/or modify it
100 under the same terms as Perl itself.
101
102
103
104perl v5.12.0 201M0o-o0s1e-X0:1:AttributeHelpers::Trait::String(3)