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