| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Venus::Sealed; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
56
|
use 5.018; |
|
|
3
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
16
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
64
|
|
|
6
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
76
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
14
|
use Venus::Class 'with'; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
16
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Venus::Role::Buildable'; |
|
11
|
|
|
|
|
|
|
with 'Venus::Role::Proxyable'; |
|
12
|
|
|
|
|
|
|
with 'Venus::Role::Tryable'; |
|
13
|
|
|
|
|
|
|
with 'Venus::Role::Throwable'; |
|
14
|
|
|
|
|
|
|
with 'Venus::Role::Catchable'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# BUILDERS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub build_arg { |
|
19
|
5
|
|
|
5
|
0
|
9
|
my ($self, $data) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
return { |
|
22
|
5
|
|
|
|
|
18
|
value => $data, |
|
23
|
|
|
|
|
|
|
}; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub build_args { |
|
27
|
53
|
|
|
53
|
0
|
111
|
my ($self, $data) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
53
|
100
|
66
|
|
|
228
|
if (not(keys %$data == 1 && exists $data->{value})) { |
|
30
|
13
|
50
|
|
|
|
34
|
$data = (exists $data->{value}) ? {value => $data->{value}} : {}; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
53
|
|
|
|
|
2551
|
require Storable; |
|
34
|
|
|
|
|
|
|
|
|
35
|
53
|
|
|
|
|
14991
|
$data = Storable::dclone($data); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $state = { |
|
38
|
53
|
100
|
|
|
|
299
|
(exists $data->{value} ? (value => $data->{value}) : ()) |
|
39
|
|
|
|
|
|
|
}; |
|
40
|
|
|
|
|
|
|
|
|
41
|
53
|
|
|
|
|
309
|
my $subs = { |
|
42
|
|
|
|
|
|
|
map +($_, $self->can($_)), grep /^__\w+$/, $self->meta->subs, |
|
43
|
|
|
|
|
|
|
}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $scope = sub { |
|
46
|
73
|
|
|
73
|
|
168
|
my ($self, $name, @args) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
73
|
50
|
|
|
|
152
|
return if !$name; |
|
49
|
|
|
|
|
|
|
|
|
50
|
73
|
|
|
|
|
140
|
my $method = "__$name"; |
|
51
|
|
|
|
|
|
|
|
|
52
|
73
|
50
|
|
|
|
170
|
return if !$subs->{$method}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
73
|
|
|
|
|
324
|
return $subs->{$method}->($self, $data, $state, @args); |
|
55
|
53
|
|
|
|
|
434
|
}; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
return { |
|
58
|
53
|
|
|
|
|
337
|
scope => $scope, |
|
59
|
|
|
|
|
|
|
}; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub build_self { |
|
63
|
53
|
|
|
53
|
0
|
108
|
my ($self, $data) = @_; |
|
64
|
|
|
|
|
|
|
|
|
65
|
53
|
|
|
|
|
106
|
return $self; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub build_proxy { |
|
69
|
73
|
|
|
73
|
0
|
186
|
my ($self, $package, $name, @args) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
73
|
|
|
|
|
216
|
my $method = $self->can("__$name"); |
|
72
|
|
|
|
|
|
|
|
|
73
|
73
|
50
|
33
|
|
|
227
|
if (!$method && ref $method ne 'CODE') { |
|
74
|
0
|
|
|
|
|
0
|
return undef; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
return sub { |
|
78
|
73
|
|
|
73
|
|
210
|
return $self->{scope}->($self, $name, @args); |
|
79
|
73
|
|
|
|
|
413
|
}; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# METHODS |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub __get { |
|
85
|
1
|
|
|
1
|
|
4
|
my ($self, $init, $data) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
8
|
return $data->{value}; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub __set { |
|
91
|
1
|
|
|
1
|
|
8
|
my ($self, $init, $data, $value) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
9
|
return $data->{value} = $value; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 NAME |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Venus::Sealed - Sealed Class |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 ABSTRACT |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Sealed Class for Perl 5 |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
package main; |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use Venus::Sealed; |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $sealed = Venus::Sealed->new('012345'); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# $sealed->get; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# '012345' |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=cut |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This package provides a mechanism for sealing object and restricting and/or |
|
129
|
|
|
|
|
|
|
preventing access to the underlying data structures. This package can be used |
|
130
|
|
|
|
|
|
|
directly but is meant to be subclassed. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 INTEGRATES |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This package integrates behaviors from: |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
L |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=cut |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 METHODS |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This package provides the following methods: |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 get |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
get(any @args) (any) |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
The get method can be used directly to get the sealed value set during |
|
161
|
|
|
|
|
|
|
instantiation, but is meant to be overridden in a subclass to further control |
|
162
|
|
|
|
|
|
|
access to the underlying data. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
I> |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=over 4 |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=item get example 1 |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# given: synopsis |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
package main; |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
my $get = $sealed->get; |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# "012345" |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=over 4 |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item get example 2 |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
package Example; |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
use Venus::Class; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
base 'Venus::Sealed'; |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
sub __get { |
|
191
|
|
|
|
|
|
|
my ($self, $init, $data) = @_; |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
return $data->{value}; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub __set { |
|
197
|
|
|
|
|
|
|
my ($self, $init, $data, $value) = @_; |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
return $data->{value} = $value; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
package main; |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
my $sealed = Example->new("012345"); |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
my $get = $sealed->get; |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# "012345" |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=back |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 set |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
set(any @args) (any) |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
The set method can be used directly to set the sealed value set during |
|
219
|
|
|
|
|
|
|
instantiation, but is meant to be overridden in a subclass to further control |
|
220
|
|
|
|
|
|
|
access to the underlying data. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
I> |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=over 4 |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item set example 1 |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# given: synopsis |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
package main; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
my $set = $sealed->set("098765"); |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
# "098765" |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=back |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=over 4 |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item set example 2 |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
package Example; |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
use Venus::Class; |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
base 'Venus::Sealed'; |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub __get { |
|
249
|
|
|
|
|
|
|
my ($self, $init, $data) = @_; |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
return $data->{value}; |
|
252
|
|
|
|
|
|
|
} |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub __set { |
|
255
|
|
|
|
|
|
|
my ($self, $init, $data, $value) = @_; |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
return $data->{value} = $value; |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
package main; |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
my $sealed = Example->new("012345"); |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
my $set = $sealed->set("098765"); |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
# "098765" |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=back |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=cut |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 AUTHORS |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
Awncorp, C |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=cut |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 LICENSE |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Copyright (C) 2000, Awncorp, C. |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
|
283
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=cut |