blib/lib/Venus/Core/Mixin.pm

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