line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Reflectable; |
2
|
|
|
|
|
|
|
|
3
|
87
|
|
|
87
|
|
1630
|
use 5.018; |
|
87
|
|
|
|
|
317
|
|
4
|
|
|
|
|
|
|
|
5
|
87
|
|
|
87
|
|
477
|
use strict; |
|
87
|
|
|
|
|
206
|
|
|
87
|
|
|
|
|
1837
|
|
6
|
87
|
|
|
87
|
|
470
|
use warnings; |
|
87
|
|
|
|
|
225
|
|
|
87
|
|
|
|
|
2549
|
|
7
|
|
|
|
|
|
|
|
8
|
87
|
|
|
87
|
|
509
|
use Venus::Role 'with'; |
|
87
|
|
|
|
|
254
|
|
|
87
|
|
|
|
|
617
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# METHODS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub class { |
13
|
2062
|
|
|
2062
|
1
|
4151
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
2062
|
|
33
|
|
|
11238
|
return ref($self) || $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub meta { |
19
|
584
|
|
|
584
|
1
|
1115
|
my ($self) = @_; |
20
|
|
|
|
|
|
|
|
21
|
584
|
|
|
|
|
2269
|
require Venus::Meta; |
22
|
|
|
|
|
|
|
|
23
|
584
|
|
|
|
|
1573
|
return Venus::Meta->new(name => $self->class); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub reify { |
27
|
3
|
|
|
3
|
1
|
11
|
my ($self, $method, @args) = @_; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
8
|
return $self->type($method, @args)->deduce; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub space { |
33
|
1
|
|
|
1
|
1
|
5
|
my ($self) = @_; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
633
|
require Venus::Space; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
7
|
return Venus::Space->new($self->class); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub type { |
41
|
5
|
|
|
5
|
1
|
14
|
my ($self, $method, @args) = @_; |
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
21
|
require Venus::Type; |
44
|
|
|
|
|
|
|
|
45
|
5
|
|
|
|
|
11
|
local $_ = $self; |
46
|
|
|
|
|
|
|
|
47
|
5
|
50
|
|
|
|
51
|
my $value = $method |
|
|
100
|
|
|
|
|
|
48
|
|
|
|
|
|
|
? $self->$method(@args) : $self->can('value') ? $self->value : $self; |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
|
|
31
|
return Venus::Type->new(value => $value); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# EXPORTS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub EXPORT { |
56
|
96
|
|
|
96
|
0
|
416
|
['class', 'meta', 'reify', 'space', 'type'] |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Venus::Role::Reflectable - Reflectable Role |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 ABSTRACT |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Reflectable Role for Perl 5 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 SYNOPSIS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
package Example; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use Venus::Class; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
with 'Venus::Role::Reflectable'; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub test { |
84
|
|
|
|
|
|
|
true |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
package main; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $example = Example->new; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# $example->space; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 DESCRIPTION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This package modifies the consuming package and provides methods for |
98
|
|
|
|
|
|
|
introspecting the object and its underlying package. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 METHODS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This package provides the following methods: |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 class |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
class() (Str) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
The class method returns the class name for the given class or object. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
I> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=over 4 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item class example 1 |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# given: synopsis; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $class = $example->class; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# "Example" |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 meta |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
meta() (Meta) |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
The meta method returns a L object for the given object. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
I> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=over 4 |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item meta example 1 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
# given: synopsis; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
my $meta = $example->meta; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# bless({name => "Example"}, "Venus::Meta") |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 reify |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
reify(Str | CodeRef $code, Any @args) (Object) |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The reify method dispatches the method call or executes the callback and |
157
|
|
|
|
|
|
|
returns the result as a value object. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
I> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=over 4 |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item reify example 1 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
# given: synopsis |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
package main; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
my $reify = $example->reify; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# bless({}, "Example") |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=back |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over 4 |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item reify example 2 |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# given: synopsis |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
package main; |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
my $reify = $example->reify('class'); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
# bless({value => "Example"}, "Venus::String") |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=back |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=over 4 |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item reify example 3 |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# given: synopsis |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
package main; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
my $reify = $example->reify('test'); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
# bless({value => 1}, "Venus::Boolean") |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=back |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 space |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
space() (Space) |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
The space method returns a L object for the given object. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
I> |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=over 4 |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item space example 1 |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# given: synopsis; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
my $space = $example->space; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# bless({ value => "Example" }, "Venus::Space") |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=back |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head2 type |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
type(Str | CodeRef $code, Any @args) (Type) |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
The type method dispatches the method call or executes the callback and returns |
232
|
|
|
|
|
|
|
the result as a L object. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
I> |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=over 4 |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item type example 1 |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# given: synopsis; |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
my $type = $example->type; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# bless({ value => bless({}, "Example") }, "Venus::Type") |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=back |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=over 4 |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item type example 2 |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# given: synopsis; |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
my $type = $example->type('class'); |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# bless({ value => "Example" }, "Venus::Type") |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=back |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=cut |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head1 AUTHORS |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Awncorp, C |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=cut |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 LICENSE |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
273
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=cut |