1Moose::Meta::Attribute:U:sNeartiCvoen:tM:roTiorbsaueit:te::dM:eSPttearr:il:nAgDt(ot3cr)uimbeunttea:t:iNoantive::Trait::String(3)
2
3
4

NAME

6       Moose::Meta::Attribute::Native::Trait::String - Helper trait for Str
7       attributes
8

SYNOPSIS

10         package MyHomePage;
11         use Moose;
12
13         has 'text' => (
14             traits    => ['String'],
15             is        => 'rw',
16             isa       => 'Str',
17             default   => q{},
18             handles   => {
19                 add_text     => 'append',
20                 replace_text => 'replace',
21             },
22         );
23
24         my $page = MyHomePage->new();
25         $page->add_text("foo"); # same as $page->text($page->text . "foo");
26

DESCRIPTION

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 handles but does use the "String" metaclass, then this module
35       applies defaults as in the "SYNOPSIS" above. This allows for a very
36       basic string definition:
37
38         has 'foo' => (traits => ['String']);
39         $obj->append_foo;
40

PROVIDED METHODS

42       These methods are implemented in
43       Moose::Meta::Attribute::Native::MethodProvider::String. It is important
44       to note that all those methods do in place modification of the value
45       stored in the attribute.
46
47       inc Increments the value stored in this slot using the magical string
48           autoincrement operator. Note that Perl doesn't provide analogous
49           behavior in "--", so "dec" is not available.
50
51       append($string)
52           Append a string, like ".=".
53
54       prepend($string)
55           Prepend a string.
56
57       replace($pattern, $replacement)
58           Performs a regexp substitution ("s" in perlop). There is no way to
59           provide the "g" flag, but code references will be accepted for the
60           replacement, causing the regex to be modified with a single "e".
61           "/smxi" can be applied using the "qr" operator.
62
63       match($pattern)
64           Like "replace" but without the replacement. Provided mostly for
65           completeness.
66
67       chop
68           "chop" in perlfunc
69
70       chomp
71           "chomp" in perlfunc
72
73       clear
74           Sets the string to the empty string (not the value passed to
75           "default").
76
77       length
78           "length" in perlfunc
79
80       substr
81           "substr" in perlfunc. We go to some lengths to match the different
82           functionality based on "substr"'s arity.
83

METHODS

85       meta
86       method_provider
87       has_method_provider
88

BUGS

90       See "BUGS" in Moose for details on reporting bugs.
91

AUTHOR

93       Stevan Little <stevan@iinteractive.com>
94
96       Copyright 2007-2009 by Infinity Interactive, Inc.
97
98       <http://www.iinteractive.com>
99
100       This library is free software; you can redistribute it and/or modify it
101       under the same terms as Perl itself.
102
103
104
105perl v5.12.2                  Moos2e0:1:0M-e0t8a-:2:8Attribute::Native::Trait::String(3)
Impressum