Mars/Kind/Mixin.pm

filter: Statementstmt 88.8% 32 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 10 / 12 Podpod 100% 5 / 5 totaltotal 88.6% 47 / 53 CC 2 SCAR 2.7
CC
2
Cov
89%
BUILD
2.0
DESTROY
2.0
IMPORT
2.0
CRAP 1.3
« Mars.pm ↑ Summary Mars/Kind/Class.pm »
1 package Mars::Kind::Mixin;
2  
3 5 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use base 'Mars::Kind';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # METHODS
11  
12 0 ▶sub BUILD {
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod documented
13 0 my ($self) = @_;
14  
15 0 return $self;
16 }
17  
18 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=6.9
19 0 my ($self) = @_;
20  
21 0 return;
22 }
23  
24 5 ▶sub EXPORT {
Subroutine EXPORT: called CC=1 SCAR=0.0
Pod documented
25 5 my ($self, $into) = @_;
26  
27 5 return [];
28 }
29  
30 9 ▶sub IMPORT {
Subroutine IMPORT: called CC=2 SCAR=6.9
Pod documented
31 9 my ($self, $into) = @_;
32  
33 5 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 5 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 9 for my $name (@{$self->EXPORT($into)}) {
37 9 *{"${into}::${name}"} = \&{"@{[$self->NAME]}::${name}"};
38 }
39  
40 9 return $self;
41 }
42  
43 1 ▶sub does {
Subroutine does: called CC=1 SCAR=0.0
Pod documented
44 1 my ($self, @args) = @_;
45  
46 1 return $self->DOES(@args);
47 }
48  
49 1 ▶sub meta {
Subroutine meta: called CC=1 SCAR=0.0
Pod documented
50 1 my ($self) = @_;
51  
52 1 return $self->META;
53 }
54  
55 5 1;
56  
57  
58  
59 =head1 NAME
60  
61 Mars::Kind::Mixin - Mixin Base Class
62  
63 =cut
64  
65 =head1 ABSTRACT
66  
67 Mixin Base Class for Perl 5
68  
69 =cut
70  
71 =head1 SYNOPSIS
72  
73 package Person;
74  
75 use base 'Mars::Kind::Mixin';
76  
77 package User;
78  
79 use base 'Mars::Kind::Class';
80  
81 package main;
82  
83 my $user = User->MIXIN('Person')->new(
84 fname => 'Elliot',
85 lname => 'Alderson',
86 );
87  
88 # bless({fname => 'Elliot', lname => 'Alderson'}, 'User')
89  
90 =cut
91  
92 =head1 DESCRIPTION
93  
94 This package provides a mixin base class with mixin building and object
95 construction lifecycle hooks.
96  
97 =cut
98  
99 =head1 INHERITS
100  
101 This package inherits behaviors from:
102  
103 L<Mars::Kind>
104  
105 =cut
106  
107 =head1 METHODS
108  
109 This package provides the following methods:
110  
111 =cut
112  
113 =head2 does
114  
115 does(Str $name) (Bool)
116  
117 The does method returns true if the object is composed of the role provided.
118  
119 I<Since C<0.05>>
120  
121 =over 4
122  
123 =item does example 1
124  
125 package Employee;
126  
127 use base 'Mars::Kind::Mixin';
128  
129 Employee->MIXIN('Person');
130  
131 package main;
132  
133 my $user = User->MIXIN('Employee')->new(
134 fname => 'Elliot',
135 lname => 'Alderson',
136 );
137  
138 my $does = Employee->does('Person');
139  
140 # 1
141  
142 =back
143  
144 =cut
145  
146 =head2 meta
147  
148 meta() (Meta)
149  
150 The meta method returns a L<Mars::Meta> objects which describes the package's
151 configuration.
152  
153 I<Since C<0.05>>
154  
155 =over 4
156  
157 =item meta example 1
158  
159 package main;
160  
161 my $user = User->MIXIN('Person')->new(
162 fname => 'Elliot',
163 lname => 'Alderson',
164 );
165  
166 my $meta = Person->meta;
167  
168 # bless({...}, 'Mars::Meta')
169  
170 =back
171  
172 =cut
173  
174 =head1 AUTHORS
175  
176 Awncorp, C<awncorp@cpan.org>
177  
178 =cut
« Mars.pm ↑ Summary Mars/Kind/Class.pm »