line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Kind; |
2
|
|
|
|
|
|
|
|
3
|
96
|
|
|
96
|
|
1999
|
use 5.018; |
|
96
|
|
|
|
|
374
|
|
4
|
|
|
|
|
|
|
|
5
|
96
|
|
|
96
|
|
540
|
use strict; |
|
96
|
|
|
|
|
201
|
|
|
96
|
|
|
|
|
2210
|
|
6
|
96
|
|
|
96
|
|
475
|
use warnings; |
|
96
|
|
|
|
|
201
|
|
|
96
|
|
|
|
|
3000
|
|
7
|
|
|
|
|
|
|
|
8
|
96
|
|
|
96
|
|
551
|
use Venus::Class 'with'; |
|
96
|
|
|
|
|
228
|
|
|
96
|
|
|
|
|
657
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Venus::Role::Boxable'; |
11
|
|
|
|
|
|
|
with 'Venus::Role::Tryable'; |
12
|
|
|
|
|
|
|
with 'Venus::Role::Catchable'; |
13
|
|
|
|
|
|
|
with 'Venus::Role::Comparable'; |
14
|
|
|
|
|
|
|
with 'Venus::Role::Deferrable'; |
15
|
|
|
|
|
|
|
with 'Venus::Role::Dumpable'; |
16
|
|
|
|
|
|
|
with 'Venus::Role::Digestable'; |
17
|
|
|
|
|
|
|
with 'Venus::Role::Doable'; |
18
|
|
|
|
|
|
|
with 'Venus::Role::Matchable'; |
19
|
|
|
|
|
|
|
with 'Venus::Role::Printable'; |
20
|
|
|
|
|
|
|
with 'Venus::Role::Reflectable'; |
21
|
|
|
|
|
|
|
with 'Venus::Role::Testable'; |
22
|
|
|
|
|
|
|
with 'Venus::Role::Throwable'; |
23
|
|
|
|
|
|
|
with 'Venus::Role::Assertable'; |
24
|
|
|
|
|
|
|
with 'Venus::Role::Serializable'; |
25
|
|
|
|
|
|
|
with 'Venus::Role::Mockable'; |
26
|
|
|
|
|
|
|
with 'Venus::Role::Patchable'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub checksum { |
31
|
346
|
|
|
346
|
1
|
772
|
my ($self) = @_; |
32
|
|
|
|
|
|
|
|
33
|
346
|
|
|
|
|
1287
|
return $self->digest('md5', 'stringified'); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub comparer { |
37
|
797
|
|
|
797
|
0
|
1571
|
my ($self, $operation) = @_; |
38
|
|
|
|
|
|
|
|
39
|
797
|
100
|
|
|
|
1800
|
if (lc($operation) eq 'eq') { |
40
|
516
|
|
|
|
|
1947
|
return 'checksum'; |
41
|
|
|
|
|
|
|
} |
42
|
281
|
100
|
|
|
|
752
|
if (lc($operation) eq 'gt') { |
43
|
155
|
|
|
|
|
556
|
return 'numified'; |
44
|
|
|
|
|
|
|
} |
45
|
126
|
50
|
|
|
|
363
|
if (lc($operation) eq 'lt') { |
46
|
126
|
|
|
|
|
471
|
return 'numified'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
0
|
|
|
|
|
0
|
return 'stringified'; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub numified { |
54
|
663
|
|
|
663
|
1
|
1433
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
|
56
|
663
|
|
|
|
|
1963
|
return CORE::length($self->stringified); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub renew { |
60
|
7
|
|
|
7
|
1
|
18
|
my ($self, @args) = @_; |
61
|
|
|
|
|
|
|
|
62
|
7
|
|
|
|
|
24
|
my $data = $self->ARGS(@args); |
63
|
|
|
|
|
|
|
|
64
|
7
|
|
|
|
|
12
|
for my $attr (@{$self->meta->attrs}) { |
|
7
|
|
|
|
|
31
|
|
65
|
8
|
100
|
100
|
|
|
52
|
$data->{$attr} = $self->$attr if exists $self->{$attr} && !exists $data->{$attr}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
7
|
|
|
|
|
24
|
return $self->class->new($data); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub safe { |
72
|
4
|
|
|
4
|
1
|
19
|
my ($self, $method, @args) = @_; |
73
|
|
|
|
|
|
|
|
74
|
4
|
|
|
|
|
63
|
my $result = $self->trap($method, @args); |
75
|
|
|
|
|
|
|
|
76
|
4
|
50
|
|
|
|
48
|
return(wantarray ? (@$result) : $result->[0]); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub self { |
80
|
2
|
|
|
2
|
1
|
9
|
my ($self) = @_; |
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
17
|
return $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub stringified { |
86
|
1341
|
|
|
1341
|
1
|
2572
|
my ($self) = @_; |
87
|
|
|
|
|
|
|
|
88
|
1341
|
100
|
|
|
|
7005
|
return $self->dump($self->can('value') ? 'value' : ()); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub trap { |
92
|
10
|
|
|
10
|
1
|
38
|
my ($self, $method, @args) = @_; |
93
|
|
|
|
|
|
|
|
94
|
96
|
|
|
96
|
|
820
|
no strict; |
|
96
|
|
|
|
|
274
|
|
|
96
|
|
|
|
|
3459
|
|
95
|
96
|
|
|
96
|
|
586
|
no warnings; |
|
96
|
|
|
|
|
246
|
|
|
96
|
|
|
|
|
29014
|
|
96
|
|
|
|
|
|
|
|
97
|
10
|
|
|
|
|
34
|
my $result = [[],[],[]]; |
98
|
|
|
|
|
|
|
|
99
|
10
|
0
|
|
|
|
49
|
return(wantarray ? (@$result) : $result->[0]) if !$method; |
|
|
50
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
10
|
|
|
|
|
79
|
local ($!, $?, $@, $^E); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
local $SIG{__DIE__} = sub{ |
104
|
5
|
|
|
5
|
|
17
|
push @{$result->[2]}, @_; |
|
5
|
|
|
|
|
76
|
|
105
|
10
|
|
|
|
|
88
|
}; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub{ |
108
|
3
|
|
|
3
|
|
6
|
push @{$result->[1]}, @_; |
|
3
|
|
|
|
|
17
|
|
109
|
10
|
|
|
|
|
59
|
}; |
110
|
|
|
|
|
|
|
|
111
|
10
|
|
|
|
|
28
|
push @{$result->[0]}, eval { |
|
10
|
|
|
|
|
26
|
|
112
|
10
|
|
|
|
|
27
|
local $_ = $self; |
113
|
10
|
|
|
|
|
141
|
$self->$method(@args); |
114
|
|
|
|
|
|
|
}; |
115
|
|
|
|
|
|
|
|
116
|
10
|
100
|
|
|
|
272
|
return(wantarray ? (@$result) : $result->[0]); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
1; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 NAME |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Venus::Kind - Kind Base Class |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 ABSTRACT |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Kind Base Class for Perl 5 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SYNOPSIS |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
package Example; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
use Venus::Class; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
base 'Venus::Kind'; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
package main; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $example = Example->new; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# bless({}, "Example") |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 DESCRIPTION |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This package provides identity and methods common across all L classes. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 INTEGRATES |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This package integrates behaviors from: |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
L |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
L |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
L |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
L |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
L |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
L |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
L |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
L |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
L |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
L |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
L |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
L |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 METHODS |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This package provides the following methods: |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 assertion |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
assertion() (Venus::Assert) |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
The assertion method returns a L object based on the invocant. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
I> |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=over 4 |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item assertion example 1 |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# given: synopsis |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
package main; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
my $assertion = $example->assertion; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# bless({name => "Example"}, "Venus::Assert") |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=back |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head2 checksum |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
checksum() (string) |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
The checksum method returns an md5 hash string representing the stringified |
232
|
|
|
|
|
|
|
object value (or the object itself). |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
I> |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=over 4 |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item checksum example 1 |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# given: synopsis; |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
my $checksum = $example->checksum; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# "859a86eed4b2d97eb7b830b02f06de32" |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=back |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=over 4 |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item checksum example 2 |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
package Checksum::Example; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
use Venus::Class; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
base 'Venus::Kind'; |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
attr 'value'; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
package main; |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
my $example = Checksum::Example->new(value => 'example'); |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
my $checksum = $example->checksum; |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
# "1a79a4d60de6718e8e5b326e338ae533" |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=back |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=cut |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head2 numified |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
numified() (number) |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
The numified method returns the numerical representation of the object which is |
277
|
|
|
|
|
|
|
typically the length (or character count) of the stringified object. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
I> |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=over 4 |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=item numified example 1 |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# given: synopsis; |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
my $numified = $example->numified; |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
# 22 |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=back |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
=over 4 |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=item numified example 2 |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
package Numified::Example; |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
use Venus::Class; |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
base 'Venus::Kind'; |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
attr 'value'; |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
package main; |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
my $example = Numified::Example->new(value => 'example'); |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
my $numified = $example->numified; |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
# 7 |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=back |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=cut |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=head2 renew |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
renew(any @args) (object) |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
The renew method returns a new instance of the invocant by instantiating the |
322
|
|
|
|
|
|
|
underlying class passing all recognized class attributes to the constructor. |
323
|
|
|
|
|
|
|
B This method is not analogous to C, i.e. attributes which are |
324
|
|
|
|
|
|
|
references will be passed to the new object as references. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
I> |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=over 4 |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=item renew example 1 |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
# given: synopsis |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
package main; |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
my $renew = $example->renew; |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
# bless({}, "Example") |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=back |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=over 4 |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
=item renew example 2 |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
package Example; |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
use Venus::Class; |
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
base 'Venus::Kind'; |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
attr 'values'; |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
package main; |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
my $example = Example->new(values => [1,2]); |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
my $renew = $example->renew; |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
# bless({values => [1,2]}, "Example") |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
=back |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=over 4 |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=item renew example 3 |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
package Example; |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
use Venus::Class; |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
base 'Venus::Kind'; |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
attr 'keys'; |
375
|
|
|
|
|
|
|
attr 'values'; |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
package main; |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
my $example = Example->new(values => [1,2]); |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
my $renew = $example->renew(keys => ['a','b']); |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
# bless({keys => ["a","b"], values => [1,2]}, "Example") |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
=back |
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=cut |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
=head2 safe |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
safe(string | coderef $code, any @args) (any) |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
The safe method dispatches the method call or executes the callback and returns |
394
|
|
|
|
|
|
|
the result, supressing warnings and exceptions. If an exception is thrown this |
395
|
|
|
|
|
|
|
method will return C. This method supports dispatching, i.e. providing a |
396
|
|
|
|
|
|
|
method name and arguments whose return value will be acted on by this method. |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
I> |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
=over 4 |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=item safe example 1 |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
# given: synopsis; |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
my $safe = $example->safe('class'); |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
# "Example" |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
=back |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=over 4 |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
=item safe example 2 |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
# given: synopsis; |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
my $safe = $example->safe(sub { |
419
|
|
|
|
|
|
|
${_}->class / 2 |
420
|
|
|
|
|
|
|
}); |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
# '0' |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
=back |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=over 4 |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=item safe example 3 |
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
# given: synopsis; |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
my $safe = $example->safe(sub { |
433
|
|
|
|
|
|
|
die; |
434
|
|
|
|
|
|
|
}); |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
# undef |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
=back |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
=cut |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
=head2 self |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
self() (any) |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
The self method returns the invocant. |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
I> |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
=over 4 |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
=item self example 1 |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
# given: synopsis |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
package main; |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
my $self = $example->self; |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
# bless({}, "Example") |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
=back |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
=cut |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=head2 stringified |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
stringified() (string) |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
The stringified method returns the object, stringified (i.e. a dump of the |
471
|
|
|
|
|
|
|
object's value). |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
I> |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=over 4 |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=item stringified example 1 |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
# given: synopsis; |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
my $stringified = $example->stringified; |
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
# bless({}, 'Example') |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
=back |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
=over 4 |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
=item stringified example 2 |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
package Stringified::Example; |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
use Venus::Class; |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
base 'Venus::Kind'; |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
attr 'value'; |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
package main; |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
my $example = Stringified::Example->new(value => 'example'); |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
my $stringified = $example->stringified; |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
# "example" |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=back |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=cut |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
=head2 trap |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
trap(string | coderef $code, any @args) (tuple[arrayref, arrayref, arrayref]) |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
The trap method dispatches the method call or executes the callback and returns |
519
|
|
|
|
|
|
|
a tuple (i.e. a 3-element arrayref) with the results, warnings, and exceptions |
520
|
|
|
|
|
|
|
from the code execution. If an exception is thrown, the results (i.e. the |
521
|
|
|
|
|
|
|
1st-element) will be an empty arrayref. This method supports dispatching, i.e. |
522
|
|
|
|
|
|
|
providing a method name and arguments whose return value will be acted on by |
523
|
|
|
|
|
|
|
this method. |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
I> |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=over 4 |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
=item trap example 1 |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
# given: synopsis; |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
my $result = $example->trap('class'); |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
# ["Example"] |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=back |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=over 4 |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
=item trap example 2 |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
# given: synopsis; |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
my ($results, $warnings, $errors) = $example->trap('class'); |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
# (["Example"], [], []) |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
=back |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=over 4 |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=item trap example 3 |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
# given: synopsis; |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
my $trap = $example->trap(sub { |
558
|
|
|
|
|
|
|
${_}->class / 2 |
559
|
|
|
|
|
|
|
}); |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
# ["0"] |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
=back |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=over 4 |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
=item trap example 4 |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
# given: synopsis; |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
my ($results, $warnings, $errors) = $example->trap(sub { |
572
|
|
|
|
|
|
|
${_}->class / 2 |
573
|
|
|
|
|
|
|
}); |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
# (["0"], ["Argument ... isn't numeric in division ..."], []) |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
=back |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=over 4 |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
=item trap example 5 |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
# given: synopsis; |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
my $trap = $example->trap(sub { |
586
|
|
|
|
|
|
|
die; |
587
|
|
|
|
|
|
|
}); |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
# [] |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=back |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
=over 4 |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=item trap example 6 |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
# given: synopsis; |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
my ($results, $warnings, $errors) = $example->trap(sub { |
600
|
|
|
|
|
|
|
die; |
601
|
|
|
|
|
|
|
}); |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
# ([], [], ["Died..."]) |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
=back |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
=cut |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=head1 AUTHORS |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
Awncorp, C |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
=cut |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=head1 LICENSE |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
Copyright (C) 2000, Awncorp, C. |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
620
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
=cut |