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