line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Kind::Value; |
2
|
|
|
|
|
|
|
|
3
|
32
|
|
|
32
|
|
620
|
use 5.018; |
|
32
|
|
|
|
|
122
|
|
4
|
|
|
|
|
|
|
|
5
|
32
|
|
|
32
|
|
215
|
use strict; |
|
32
|
|
|
|
|
70
|
|
|
32
|
|
|
|
|
726
|
|
6
|
32
|
|
|
32
|
|
182
|
use warnings; |
|
32
|
|
|
|
|
349
|
|
|
32
|
|
|
|
|
1368
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use overload ( |
9
|
32
|
|
|
|
|
355
|
'""' => 'explain', |
10
|
|
|
|
|
|
|
'~~' => 'explain', |
11
|
|
|
|
|
|
|
fallback => 1, |
12
|
32
|
|
|
32
|
|
190
|
); |
|
32
|
|
|
|
|
107
|
|
13
|
|
|
|
|
|
|
|
14
|
32
|
|
|
32
|
|
3618
|
use Venus::Class 'base', 'with'; |
|
32
|
|
|
|
|
118
|
|
|
32
|
|
|
|
|
319
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
base 'Venus::Kind'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
with 'Venus::Role::Valuable'; |
19
|
|
|
|
|
|
|
with 'Venus::Role::Buildable'; |
20
|
|
|
|
|
|
|
with 'Venus::Role::Accessible'; |
21
|
|
|
|
|
|
|
with 'Venus::Role::Explainable'; |
22
|
|
|
|
|
|
|
with 'Venus::Role::Proxyable'; |
23
|
|
|
|
|
|
|
with 'Venus::Role::Pluggable'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# BUILDERS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub build_arg { |
28
|
722
|
|
|
722
|
0
|
1786
|
my ($self, $data) = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return { |
31
|
722
|
|
|
|
|
2915
|
value => $data, |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# METHODS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub cast { |
38
|
103
|
|
|
103
|
1
|
362
|
my ($self, @args) = @_; |
39
|
|
|
|
|
|
|
|
40
|
103
|
|
|
|
|
488
|
require Venus::Type; |
41
|
|
|
|
|
|
|
|
42
|
103
|
50
|
|
|
|
615
|
my $value = $self->can('value') ? $self->value : $self; |
43
|
|
|
|
|
|
|
|
44
|
103
|
|
|
|
|
881
|
return Venus::Type->new(value => $value)->cast(@args); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub defined { |
48
|
2
|
|
|
2
|
1
|
5
|
my ($self) = @_; |
49
|
|
|
|
|
|
|
|
50
|
2
|
100
|
|
|
|
7
|
return CORE::defined($self->get) ? true : false; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub explain { |
54
|
506
|
|
|
506
|
1
|
11495
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
|
56
|
506
|
|
|
|
|
1612
|
return $self->get; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub mutate { |
60
|
2
|
|
|
2
|
1
|
8
|
my ($self, $code, @args) = @_; |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
45
|
return $self->set($self->$code(@args)); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub TO_JSON { |
66
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return $self->get; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Venus::Kind::Value - Value Base Class |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 ABSTRACT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Value Base Class for Perl 5 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
package Example; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use Venus::Class; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
base 'Venus::Kind::Value'; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub test { |
96
|
|
|
|
|
|
|
$_[0]->get + 1 |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
package main; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $example = Example->new(1); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# $example->defined; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This package provides identity and methods common across all L value |
110
|
|
|
|
|
|
|
classes. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 INHERITS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This package inherits behaviors from: |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 INTEGRATES |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This package integrates behaviors from: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
L |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
L |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 METHODS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
This package provides the following methods: |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=cut |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 cast |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
cast(string $kind) (object | undef) |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
The cast method converts L<"value"|Venus::Kind::Value> objects between |
151
|
|
|
|
|
|
|
different I<"value"> object types, based on the name of the type provided. This |
152
|
|
|
|
|
|
|
method will return C if the invocant is not a L. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
I> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=over 4 |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item cast example 1 |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
package main; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my $example = Example->new; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $cast = $example->cast; |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# bless({value => undef}, "Venus::Undef") |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=over 4 |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item cast example 2 |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
package main; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
my $example = Example->new( |
177
|
|
|
|
|
|
|
value => 123.45, |
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
my $cast = $example->cast('array'); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# bless({value => [123.45]}, "Venus::Array") |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=back |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=over 4 |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item cast example 3 |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
package main; |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
my $example = Example->new( |
193
|
|
|
|
|
|
|
value => 123.45, |
194
|
|
|
|
|
|
|
); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
my $cast = $example->cast('hash'); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# bless({value => {'123.45' => 123.45}, "Venus::Hash") |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=back |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 defined |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
defined() (number) |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
The defined method returns truthy or falsy if the underlying value is |
209
|
|
|
|
|
|
|
L. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
I> |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=over 4 |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item defined example 1 |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
package main; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
my $example = Example->new; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
my $defined = $example->defined; |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# 0 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=back |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=over 4 |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item defined example 2 |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
package main; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
my $example = Example->new(time); |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
my $defined = $example->defined; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# 1 |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=back |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=cut |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 explain |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
explain() (any) |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
The explain method returns the value set and is used in stringification |
248
|
|
|
|
|
|
|
operations. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
I> |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=over 4 |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item explain example 1 |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
package main; |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
my $example = Example->new('hello, there'); |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
my $explain = $example->explain; |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
# "hello, there" |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=back |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=cut |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head2 mutate |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
mutate(string | coderef $code, any @args) (object) |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
The mutate method dispatches the method call or executes the callback and |
273
|
|
|
|
|
|
|
returns the result, which if is of the same type as the invocant's underlying |
274
|
|
|
|
|
|
|
data type will update the object's internal state or will throw an exception. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
I> |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=over 4 |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item mutate example 1 |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# given: synopsis |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
package main; |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
$example->mutate('test'); |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
$example; |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
# bless({value => 2}, "Example") |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=back |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=head1 AUTHORS |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Awncorp, C |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=cut |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head1 LICENSE |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Copyright (C) 2000, Awncorp, C. |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
307
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=cut |