line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mars::Kind::Role; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
4267
|
use 5.018; |
|
6
|
|
|
|
|
18
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
24
|
use strict; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
100
|
|
6
|
6
|
|
|
6
|
|
21
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
152
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
92
|
use base 'Mars::Kind'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
1063
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# METHODS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub BUILD { |
13
|
0
|
|
|
0
|
1
|
0
|
my ($self, @data) = @_; |
14
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
34
|
no strict 'refs'; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
739
|
|
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
0
|
my @roles = @{$self->META->roles}; |
|
0
|
|
|
|
|
0
|
|
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
for my $action (grep defined, map *{"${_}::BUILD"}{"CODE"}, @roles) { |
|
0
|
|
|
|
|
0
|
|
20
|
0
|
|
|
|
|
0
|
$self->$action(@data); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub DESTROY { |
27
|
0
|
|
|
0
|
|
0
|
my ($self, @data) = @_; |
28
|
|
|
|
|
|
|
|
29
|
6
|
|
|
6
|
|
32
|
no strict 'refs'; |
|
6
|
|
|
|
|
36
|
|
|
6
|
|
|
|
|
884
|
|
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
my @roles = @{$self->META->roles}; |
|
0
|
|
|
|
|
0
|
|
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
for my $action (grep defined, map *{"${_}::DESTROY"}{"CODE"}, @roles) { |
|
0
|
|
|
|
|
0
|
|
34
|
0
|
|
|
|
|
0
|
$self->$action(@data); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
0
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub EXPORT { |
41
|
17
|
|
|
17
|
1
|
32
|
my ($self, $into) = @_; |
42
|
|
|
|
|
|
|
|
43
|
17
|
|
|
|
|
57
|
return []; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub IMPORT { |
47
|
32
|
|
|
32
|
1
|
90
|
my ($self, $into) = @_; |
48
|
|
|
|
|
|
|
|
49
|
6
|
|
|
6
|
|
37
|
no strict 'refs'; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
182
|
|
50
|
6
|
|
|
6
|
|
30
|
no warnings 'redefine'; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
1185
|
|
51
|
|
|
|
|
|
|
|
52
|
32
|
|
|
|
|
65
|
for my $name (grep !*{"${into}::${_}"}{"CODE"}, @{$self->EXPORT($into)}) { |
|
23
|
|
|
|
|
144
|
|
|
32
|
|
|
|
|
220
|
|
53
|
23
|
|
|
|
|
30
|
*{"${into}::${name}"} = \&{"@{[$self->NAME]}::${name}"}; |
|
23
|
|
|
|
|
67
|
|
|
23
|
|
|
|
|
25
|
|
|
23
|
|
|
|
|
81
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
32
|
|
|
|
|
81
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub does { |
60
|
1
|
|
|
1
|
1
|
7
|
my ($self, @args) = @_; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
3
|
return $self->DOES(@args); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub meta { |
66
|
1
|
|
|
1
|
1
|
7
|
my ($self) = @_; |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
3
|
return $self->META; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Mars::Kind::Role - Role Base Class |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 ABSTRACT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Role Base Class for Perl 5 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
package Person; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use base 'Mars::Kind::Role'; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
package User; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
use base 'Mars::Kind::Class'; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
package main; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $user = User->ROLE('Person')->new( |
100
|
|
|
|
|
|
|
fname => 'Elliot', |
101
|
|
|
|
|
|
|
lname => 'Alderson', |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# bless({fname => 'Elliot', lname => 'Alderson'}, 'User') |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 DESCRIPTION |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This package provides a role base class with role building and object |
111
|
|
|
|
|
|
|
construction lifecycle hooks. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 INHERITS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This package inherits behaviors from: |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
L |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 METHODS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This package provides the following methods: |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 does |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
does(Str $name) (Bool) |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The does method returns true if the object is composed of the role provided. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
I> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over 4 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item does example 1 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
package Employee; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
use base 'Mars::Kind::Role'; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Employee->ROLE('Person'); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
package main; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
my $user = User->ROLE('Employee')->new( |
150
|
|
|
|
|
|
|
fname => 'Elliot', |
151
|
|
|
|
|
|
|
lname => 'Alderson', |
152
|
|
|
|
|
|
|
); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
my $does = Employee->does('Person'); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# 1 |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 meta |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
meta() (Meta) |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The meta method returns a L objects which describes the package's |
167
|
|
|
|
|
|
|
configuration. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
I> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=over 4 |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item meta example 1 |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
package main; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
my $user = User->ROLE('Person')->new( |
178
|
|
|
|
|
|
|
fname => 'Elliot', |
179
|
|
|
|
|
|
|
lname => 'Alderson', |
180
|
|
|
|
|
|
|
); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
my $meta = Person->meta; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# bless({...}, 'Mars::Meta') |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=back |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=head1 AUTHORS |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Awncorp, C |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |