line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::Attribute::Native::Trait::String; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2203'; |
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
4186
|
use Moose::Role; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
with 'Moose::Meta::Attribute::Native::Trait'; |
6
|
|
|
|
|
|
|
|
7
|
136
|
|
|
136
|
|
553
|
sub _helper_type { 'Str' } |
8
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
47
|
no Moose::Role; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
26
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
1; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: Helper trait for Str attributes |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__END__ |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=pod |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=encoding UTF-8 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Moose::Meta::Attribute::Native::Trait::String - Helper trait for Str attributes |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
version 2.2203 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
package MyHomePage; |
32
|
|
|
|
|
|
|
use Moose; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'text' => ( |
35
|
|
|
|
|
|
|
traits => ['String'], |
36
|
|
|
|
|
|
|
is => 'rw', |
37
|
|
|
|
|
|
|
isa => 'Str', |
38
|
|
|
|
|
|
|
default => q{}, |
39
|
|
|
|
|
|
|
handles => { |
40
|
|
|
|
|
|
|
add_text => 'append', |
41
|
|
|
|
|
|
|
replace_text => 'replace', |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $page = MyHomePage->new(); |
46
|
|
|
|
|
|
|
$page->add_text("foo"); # same as $page->text($page->text . "foo"); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This trait provides native delegation methods for strings. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DEFAULT TYPE |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
If you don't provide an C<isa> value for your attribute, it will default to |
55
|
|
|
|
|
|
|
C<Str>. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 PROVIDED METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=over 4 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item * B<inc> |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Increments the value stored in this slot using the magical string autoincrement |
64
|
|
|
|
|
|
|
operator. Note that Perl doesn't provide analogous behavior in C<-->, so |
65
|
|
|
|
|
|
|
C<dec> is not available. This method returns the new value. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
This method does not accept any arguments. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item * B<append($string)> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Appends to the string, like C<.=>, and returns the new value. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This method requires a single argument. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * B<prepend($string)> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Prepends to the string and returns the new value. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This method requires a single argument. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * B<replace($pattern, $replacement)> |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Performs a regexp substitution (L<perlop/s>). There is no way to provide the |
84
|
|
|
|
|
|
|
C<g> flag, but code references will be accepted for the replacement, causing |
85
|
|
|
|
|
|
|
the regex to be modified with a single C<e>. C</smxi> can be applied using the |
86
|
|
|
|
|
|
|
C<qr> operator. This method returns the new value. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This method requires two arguments. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item * B<match($pattern)> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Runs the regex against the string and returns the matching value(s). |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This method requires a single argument. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * B<chop> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Just like L<perlfunc/chop>. This method returns the chopped character. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This method does not accept any arguments. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * B<chomp> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Just like L<perlfunc/chomp>. This method returns the number of characters |
105
|
|
|
|
|
|
|
removed. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This method does not accept any arguments. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * B<clear> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Sets the string to the empty string (not the value passed to C<default>). |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This method does not have a defined return value. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This method does not accept any arguments. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * B<length> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Just like L<perlfunc/length>, returns the length of the string. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * B<substr> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This acts just like L<perlfunc/substr>. When called as a writer, it returns |
124
|
|
|
|
|
|
|
the substring that was replaced, just like the Perl builtin. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This method requires at least one argument, and accepts no more than three. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=back |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 BUGS |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
See L<Moose/BUGS> for details on reporting bugs. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 AUTHORS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=over 4 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Shawn M Moore <sartak@cpan.org> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item * |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item * |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item * |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Hans Dieter Pearcey <hdp@cpan.org> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item * |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Chris Prather <chris@prather.org> |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Matt S Trout <mstrout@cpan.org> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
185
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut |