blib/lib/Venus/Core/Class.pm

filter: Statementstmt 86.9% 60 / 69 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 94.4% 17 / 18 Podpod 50.0% 3 / 6 totaltotal 86.0% 80 / 93 SCAR 16.2
CC
5
Cov
87%
DESTROY
3.0
IMPORT
2.1
BUILD
2.0
CRAP 5.1
« blib/lib/Venus/Schema.pm ↑ Summary blib/lib/Venus/Role/Accessible.pm »
1 package Venus::Core::Class;
2  
3 96 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 96 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 96 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 96 ▶no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 96 ▶use base 'Venus::Core';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # METHODS
13  
14 sub BUILD {
15 15539 ▶ my ($self, @data) = @_;
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
16  
17 96 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 15539 my @roles = @{$self->META->roles};
20  
21 15539 for my $action (grep defined, map *{"${_}::BUILD"}{"CODE"}, @roles) {
22 24414 $self->$action(@data);
23 }
24  
25 15530 return $self;
26 }
27  
28 sub DESTROY {
29 14970 ▶ my ($self, @data) = @_;
Subroutine DESTROY: called CC=3 SCAR=11.1
30  
31 96 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 14970 my @mixins = @{$self->META->mixins};
34  
35 14970 for my $action (grep defined, map *{"${_}::DESTROY"}{"CODE"}, @mixins) {
36 0 $self->$action(@data);
37 }
38  
39 14970 my @roles = @{$self->META->roles};
40  
41 14970 for my $action (grep defined, map *{"${_}::DESTROY"}{"CODE"}, @roles) {
42 0 $self->$action(@data);
43 }
44  
45 14970 return $self;
46 }
47  
48 sub does {
49 449 ▶ my ($self, @args) = @_;
Subroutine does: called CC=1 SCAR=0.0
Pod documented
50  
51 449 return $self->DOES(@args);
52 }
53  
54 sub EXPORT {
55 3350 ▶ my ($self, $into) = @_;
Subroutine EXPORT: called CC=1 SCAR=0.0
Pod undocumented
56  
57 3350 return [];
58 }
59  
60 sub IMPORT {
61 3350 ▶ my ($self, $into) = @_;
Subroutine IMPORT: called CC=2 SCAR=7.4
Pod undocumented
62  
63 96 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
64 96 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
65  
66 3350 for my $name (@{$self->EXPORT($into)}) {
67 0 *{"${into}::${name}"} = \&{"@{[$self->NAME]}::${name}"};
68 }
69  
70 3350 return $self;
71 }
72  
73 sub import {
74 3347 ▶ my ($self, @args) = @_;
Subroutine import: called CC=1 SCAR=0.0
75  
76 3347 my $target = caller;
77  
78 3347 $self->USE($target);
79  
80 3347 return $self->IMPORT($target, @args);
81 }
82  
83 sub meta {
84 87 ▶ my ($self) = @_;
Subroutine meta: called CC=1 SCAR=0.0
Pod documented
85  
86 87 return $self->META;
87 }
88  
89 sub new {
90 15539 ▶ my ($self, @args) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
91  
92 15539 return $self->BLESS(@args);
93 }
94  
95 sub unimport {
96 0 ▶ my ($self, @args) = @_;
Subroutine unimport: not called CC=1 SCAR=6.9
97  
98 0 my $target = caller;
99  
100 0 return $self->UNIMPORT($target, @args);
101 }
102  
103 96 1;
104  
105  
106  
107 =head1 NAME
108  
109 Venus::Core::Class - Class Base Class
110  
111 =cut
112  
113 =head1 ABSTRACT
114  
115 Class Base Class for Perl 5
116  
117 =cut
118  
119 =head1 SYNOPSIS
120  
121 package User;
122  
123 use base 'Venus::Core::Class';
124  
125 package main;
126  
127 my $user = User->new(
128 fname => 'Elliot',
129 lname => 'Alderson',
130 );
131  
132 # bless({fname => 'Elliot', lname => 'Alderson'}, 'User')
133  
134 =cut
135  
136 =head1 DESCRIPTION
137  
138 This package provides a class base class with class building and object
139 construction lifecycle hooks.
140  
141 =cut
142  
143 =head1 INHERITS
144  
145 This package inherits behaviors from:
146  
147 L<Venus::Core>
148  
149 =cut
150  
151 =head1 METHODS
152  
153 This package provides the following methods:
154  
155 =cut
156  
157 =head2 does
158  
159 does(string $name) (boolean)
160  
161 The does method returns true if the object is composed of the role provided.
162  
163 I<Since C<1.00>>
164  
165 =over 4
166  
167 =item does example 1
168  
169 # given: synopsis
170  
171 my $does = $user->does('Identity');
172  
173 # 0
174  
175 =back
176  
177 =cut
178  
179 =head2 import
180  
181 import(any @args) (any)
182  
183 The import method invokes the C<IMPORT> lifecycle hook and is invoked whenever
184 the L<perlfunc/use> declaration is used.
185  
186 I<Since C<2.91>>
187  
188 =over 4
189  
190 =item import example 1
191  
192 package main;
193  
194 use User;
195  
196 # ()
197  
198 =back
199  
200 =cut
201  
202 =head2 meta
203  
204 meta() (Venus::Meta)
205  
206 The meta method returns a L<Venus::Meta> objects which describes the package's
207 configuration.
208  
209 I<Since C<1.00>>
210  
211 =over 4
212  
213 =item meta example 1
214  
215 package main;
216  
217 my $user = User->new(
218 fname => 'Elliot',
219 lname => 'Alderson',
220 );
221  
222 my $meta = $user->meta;
223  
224 # bless({...}, 'Venus::Meta')
225  
226 =back
227  
228 =cut
229  
230 =head2 new
231  
232 new(any %args | hashref $args) (object)
233  
234 The new method instantiates the class and returns a new object.
235  
236 I<Since C<1.00>>
237  
238 =over 4
239  
240 =item new example 1
241  
242 package main;
243  
244 my $user = User->new(
245 fname => 'Elliot',
246 lname => 'Alderson',
247 );
248  
249 # bless({fname => 'Elliot', lname => 'Alderson'}, 'User')
250  
251 =back
252  
253 =over 4
254  
255 =item new example 2
256  
257 package main;
258  
259 my $user = User->new({
260 fname => 'Elliot',
261 lname => 'Alderson',
262 });
263  
264 # bless({fname => 'Elliot', lname => 'Alderson'}, 'User')
265  
266 =back
267  
268 =cut
269  
270 =head2 unimport
271  
272 unimport(any @args) (any)
273  
274 The unimport method invokes the C<UNIMPORT> lifecycle hook and is invoked
275 whenever the L<perlfunc/no> declaration is used.
276  
277 I<Since C<2.91>>
278  
279 =over 4
280  
281 =item unimport example 1
282  
283 package main;
284  
285 no User;
286  
287 # ()
288  
289 =back
290  
291 =cut
292  
293 =head1 AUTHORS
294  
295 Awncorp, C<awncorp@cpan.org>
296  
297 =cut
298  
299 =head1 LICENSE
300  
301 Copyright (C) 2000, Awncorp, C<awncorp@cpan.org>.
302  
303 This program is free software, you can redistribute it and/or modify it under
304 the terms of the Apache license version 2.0.
305  
306 =cut
« blib/lib/Venus/Schema.pm ↑ Summary blib/lib/Venus/Role/Accessible.pm »