1MooseX::AttributeHelperUss:e:rStCroinntgr(i3bpumt)ed PerMlooDsoecXu:m:eAntttartiibounteHelpers::String(3pm)
2
3
4
6 MooseX::AttributeHelpers::String
7
9 version 0.25
10
12 package MyHomePage;
13 use Moose;
14 use MooseX::AttributeHelpers;
15
16 has 'text' => (
17 metaclass => 'String',
18 is => 'rw',
19 isa => 'Str',
20 default => sub { '' },
21 provides => {
22 append => "add_text",
23 replace => "replace_text",
24 }
25 );
26
27 my $page = MyHomePage->new();
28 $page->add_text("foo"); # same as $page->text($page->text . "foo");
29
31 This module provides a simple string attribute, to which mutating
32 string operations can be applied more easily (no need to make an lvalue
33 attribute metaclass or use temporary variables). Additional methods are
34 provided for completion.
35
36 If your attribute definition does not include any of is, isa, default
37 or provides but does use the "String" metaclass, then this module
38 applies defaults as in the "SYNOPSIS" above. This allows for a very
39 basic counter definition:
40
41 has 'foo' => (metaclass => 'String');
42 $obj->append_foo;
43
45 meta
46 method_provider
47 has_method_provider
48 helper_type
49 process_options_for_provides
50 Run before its superclass method.
51
52 check_provides_values
53 Run after its superclass method.
54
56 It is important to note that all those methods do in place modification
57 of the value stored in the attribute.
58
59 inc Increments the value stored in this slot using the magical string
60 autoincrement operator. Note that Perl doesn't provide analogeous
61 behavior in "--", so "dec" is not available.
62
63 append $string
64 Append a string, like ".=".
65
66 prepend $string
67 Prepend a string.
68
69 replace $pattern $replacement
70 Performs a regexp substitution ("s" in perlop). There is no way to
71 provide the "g" flag, but code references will be accepted for the
72 replacement, causing the regex to be modified with a single "e".
73 "/smxi" can be applied using the "qr" operator.
74
75 match $pattern
76 Like replace but without the replacement. Provided mostly for
77 completeness.
78
79 "chop"
80 "chop" in perlfunc
81
82 "chomp"
83 "chomp" in perlfunc
84
85 "clear"
86 Sets the string to the empty string (not the value passed to
87 "default").
88
90 Bugs may be submitted through the RT bug tracker
91 <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-
92 AttributeHelpers> (or bug-MooseX-AttributeHelpers@rt.cpan.org
93 <mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>).
94
95 There is also a mailing list available for users of this distribution,
96 at <http://lists.perl.org/list/moose.html>.
97
98 There is also an irc channel available for users of this distribution,
99 at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
100
102 Stevan Little <stevan@iinteractive.com>
103
105 This software is copyright (c) 2007 by Stevan Little and Infinity
106 Interactive, Inc.
107
108 This is free software; you can redistribute it and/or modify it under
109 the same terms as the Perl 5 programming language system itself.
110
111
112
113perl v5.32.1 2021-01-M2o7oseX::AttributeHelpers::String(3pm)