line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Core::Role; |
2
|
|
|
|
|
|
|
|
3
|
87
|
|
|
87
|
|
1519
|
use 5.018; |
|
87
|
|
|
|
|
301
|
|
4
|
|
|
|
|
|
|
|
5
|
87
|
|
|
87
|
|
546
|
use strict; |
|
87
|
|
|
|
|
252
|
|
|
87
|
|
|
|
|
2129
|
|
6
|
87
|
|
|
87
|
|
524
|
use warnings; |
|
87
|
|
|
|
|
214
|
|
|
87
|
|
|
|
|
2861
|
|
7
|
|
|
|
|
|
|
|
8
|
87
|
|
|
87
|
|
497
|
no warnings 'once'; |
|
87
|
|
|
|
|
237
|
|
|
87
|
|
|
|
|
3369
|
|
9
|
|
|
|
|
|
|
|
10
|
87
|
|
|
87
|
|
534
|
use base 'Venus::Core'; |
|
87
|
|
|
|
|
187
|
|
|
87
|
|
|
|
|
12648
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# METHODS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub BUILD { |
15
|
0
|
|
|
0
|
0
|
0
|
my ($self, @data) = @_; |
16
|
|
|
|
|
|
|
|
17
|
87
|
|
|
87
|
|
631
|
no strict 'refs'; |
|
87
|
|
|
|
|
184
|
|
|
87
|
|
|
|
|
12989
|
|
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
my @roles = @{$self->META->roles}; |
|
0
|
|
|
|
|
0
|
|
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
for my $action (grep defined, map *{"${_}::BUILD"}{"CODE"}, @roles) { |
|
0
|
|
|
|
|
0
|
|
22
|
0
|
|
|
|
|
0
|
$self->$action(@data); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub DESTROY { |
29
|
0
|
|
|
0
|
|
0
|
my ($self, @data) = @_; |
30
|
|
|
|
|
|
|
|
31
|
87
|
|
|
87
|
|
652
|
no strict 'refs'; |
|
87
|
|
|
|
|
205
|
|
|
87
|
|
|
|
|
19887
|
|
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
my @mixins = @{$self->META->mixins}; |
|
0
|
|
|
|
|
0
|
|
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
0
|
for my $action (grep defined, map *{"${_}::DESTROY"}{"CODE"}, @mixins) { |
|
0
|
|
|
|
|
0
|
|
36
|
0
|
|
|
|
|
0
|
$self->$action(@data); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
my @roles = @{$self->META->roles}; |
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
for my $action (grep defined, map *{"${_}::DESTROY"}{"CODE"}, @roles) { |
|
0
|
|
|
|
|
0
|
|
42
|
0
|
|
|
|
|
0
|
$self->$action(@data); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
0
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub EXPORT { |
49
|
227
|
|
|
227
|
0
|
1073
|
my ($self, $into) = @_; |
50
|
|
|
|
|
|
|
|
51
|
227
|
|
|
|
|
840
|
return []; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub IMPORT { |
55
|
3159
|
|
|
3159
|
0
|
6545
|
my ($self, $into) = @_; |
56
|
|
|
|
|
|
|
|
57
|
87
|
|
|
87
|
|
662
|
no strict 'refs'; |
|
87
|
|
|
|
|
157
|
|
|
87
|
|
|
|
|
2979
|
|
58
|
87
|
|
|
87
|
|
491
|
no warnings 'redefine'; |
|
87
|
|
|
|
|
196
|
|
|
87
|
|
|
|
|
29215
|
|
59
|
|
|
|
|
|
|
|
60
|
3159
|
|
|
|
|
4678
|
for my $name (grep !*{"${into}::${_}"}{"CODE"}, @{$self->EXPORT($into)}) { |
|
7568
|
|
|
|
|
30403
|
|
|
3159
|
|
|
|
|
11530
|
|
61
|
6925
|
|
|
|
|
9469
|
*{"${into}::${name}"} = \&{"@{[$self->NAME]}::${name}"}; |
|
6925
|
|
|
|
|
25637
|
|
|
6925
|
|
|
|
|
8734
|
|
|
6925
|
|
|
|
|
17212
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
3159
|
|
|
|
|
7317
|
return $self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub does { |
68
|
1
|
|
|
1
|
1
|
4
|
my ($self, @args) = @_; |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
6
|
return $self->DOES(@args); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub import { |
74
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
require Venus; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
@_ = ("${self} cannot be used via the \"use\" declaration"); |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
goto \&Venus::fault; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub meta { |
84
|
1
|
|
|
1
|
1
|
4
|
my ($self) = @_; |
85
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
5
|
return $self->META; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub unimport { |
90
|
0
|
|
|
0
|
|
|
my ($self, @args) = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $target = caller; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
return $self->UNIMPORT($target, @args); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 NAME |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Venus::Core::Role - Role Base Class |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 ABSTRACT |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Role Base Class for Perl 5 |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SYNOPSIS |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
package Person; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
use base 'Venus::Core::Role'; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
package User; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
use base 'Venus::Core::Class'; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
package main; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $user = User->ROLE('Person')->new( |
126
|
|
|
|
|
|
|
fname => 'Elliot', |
127
|
|
|
|
|
|
|
lname => 'Alderson', |
128
|
|
|
|
|
|
|
); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# bless({fname => 'Elliot', lname => 'Alderson'}, 'User') |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 DESCRIPTION |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This package provides a role base class with role building and object |
137
|
|
|
|
|
|
|
construction lifecycle hooks. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 INHERITS |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This package inherits behaviors from: |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 METHODS |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This package provides the following methods: |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head2 does |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
does(Str $name) (Bool) |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The does method returns true if the object is composed of the role provided. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
I> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over 4 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item does example 1 |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
package Employee; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
use base 'Venus::Core::Role'; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Employee->ROLE('Person'); |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
package main; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
my $user = User->ROLE('Employee')->new( |
176
|
|
|
|
|
|
|
fname => 'Elliot', |
177
|
|
|
|
|
|
|
lname => 'Alderson', |
178
|
|
|
|
|
|
|
); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
my $does = Employee->does('Person'); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# 1 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=back |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 import |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
import(Any @args) (Any) |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
The import method throws a fatal exception whenever the L |
193
|
|
|
|
|
|
|
declaration is used with roles as they are meant to be consumed via the C |
194
|
|
|
|
|
|
|
or C keyword functions. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
I> |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=over 4 |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item import example 1 |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
package main; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
use Person; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
# Exception! (isa Venus::Fault) |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=back |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 meta |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
meta() (Meta) |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
The meta method returns a L objects which describes the package's |
217
|
|
|
|
|
|
|
configuration. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
I> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=over 4 |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item meta example 1 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
package main; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
my $user = User->ROLE('Person')->new( |
228
|
|
|
|
|
|
|
fname => 'Elliot', |
229
|
|
|
|
|
|
|
lname => 'Alderson', |
230
|
|
|
|
|
|
|
); |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
my $meta = Person->meta; |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
# bless({...}, 'Venus::Meta') |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=back |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=cut |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 unimport |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
unimport(Any @args) (Any) |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
The unimport method invokes the C lifecycle hook and is invoked |
245
|
|
|
|
|
|
|
whenever the L declaration is used. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
I> |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=over 4 |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item unimport example 1 |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
package main; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
no User; |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
# () |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=back |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=cut |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 AUTHORS |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Awncorp, C |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=cut |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 LICENSE |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
274
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=cut |