| 1 | package Mars; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use 5.018; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | # VERSION | ||||||||||
| 9 | |||||||||||
| 10 | 4 | our $VERSION = '0.05'; | |||||||||
| 11 | |||||||||||
| 12 | # AUTHORITY | ||||||||||
| 13 | |||||||||||
| 14 | 4 | our $AUTHORITY = 'cpan:AWNCORP'; | |||||||||
| 15 | |||||||||||
| 16 | # IMPORT | ||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||
| 19 | 1 | my ($self, @args) = @_; | |||||||||
| 20 | |||||||||||
| 21 | 1 | my $from = caller; | |||||||||
| 22 | |||||||||||
| 23 | 4 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | 1 | ▶ | if (!*{"${from}::true"}{"CODE"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | 1 | *{"${from}::true"} = \&true; | |||||||||
| 27 | } | ||||||||||
| 28 | 1 | ▶ | if (!*{"${from}::false"}{"CODE"}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 1 | *{"${from}::false"} = \&false; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 1 | return $self; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 15 | ▶ | sub false { | ||||||||
|
Subroutine
false: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | 15 | require Scalar::Util; | |||||||||
| 37 | 15 | state $false = Scalar::Util::dualvar(0, "0"); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 13 | ▶ | sub true { | ||||||||
|
Subroutine
true: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 41 | 13 | require Scalar::Util; | |||||||||
| 42 | 13 | state $true = Scalar::Util::dualvar(1, "1"); | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 4 | 1; | |||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | =head1 NAME | ||||||||||
| 50 | |||||||||||
| 51 | Mars - OO Framework | ||||||||||
| 52 | |||||||||||
| 53 | =cut | ||||||||||
| 54 | |||||||||||
| 55 | =head1 ABSTRACT | ||||||||||
| 56 | |||||||||||
| 57 | OO Framework for Perl 5 | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||
| 60 | |||||||||||
| 61 | =head1 VERSION | ||||||||||
| 62 | |||||||||||
| 63 | 0.05 | ||||||||||
| 64 | |||||||||||
| 65 | =cut | ||||||||||
| 66 | |||||||||||
| 67 | =head1 SYNOPSIS | ||||||||||
| 68 | |||||||||||
| 69 | package User; | ||||||||||
| 70 | |||||||||||
| 71 | use Mars::Class; | ||||||||||
| 72 | |||||||||||
| 73 | attr 'fname'; | ||||||||||
| 74 | attr 'lname'; | ||||||||||
| 75 | attr 'email'; | ||||||||||
| 76 | attr 'trust'; | ||||||||||
| 77 | |||||||||||
| 78 | sub BUILD { | ||||||||||
| 79 | shift->{trust} = true; | ||||||||||
| 80 | } | ||||||||||
| 81 | |||||||||||
| 82 | package main; | ||||||||||
| 83 | |||||||||||
| 84 | my $user = User->new( | ||||||||||
| 85 | fname => 'Elliot', | ||||||||||
| 86 | lname => 'Alderson', | ||||||||||
| 87 | ); | ||||||||||
| 88 | |||||||||||
| 89 | # bless({ | ||||||||||
| 90 | # 'fname' => 'Elliot', | ||||||||||
| 91 | # 'lname' => 'Alderson', | ||||||||||
| 92 | # 'trust' => 1 | ||||||||||
| 93 | # }, 'User') | ||||||||||
| 94 | |||||||||||
| 95 | =cut | ||||||||||
| 96 | |||||||||||
| 97 | =head1 DESCRIPTION | ||||||||||
| 98 | |||||||||||
| 99 | Mars is a simple yet powerful framework for object-oriented programming which | ||||||||||
| 100 | lets you hook into all aspects of the L<"class"|Mars::Class>, | ||||||||||
| 101 | L<"role"|Mars::Role>, L<"interface"|Mars::Role>, and object | ||||||||||
| 102 | L<"lifecycle"|Mars::Kind/METHODS>, from class declaration and object | ||||||||||
| 103 | L<"construction"|Mars::Kind/BLESS>, to object | ||||||||||
| 104 | L<"deconstruction"|Mars::Kind/DESTROY>. | ||||||||||
| 105 | |||||||||||
| 106 | =cut | ||||||||||
| 107 | |||||||||||
| 108 | =head1 FUNCTIONS | ||||||||||
| 109 | |||||||||||
| 110 | This package provides the following functions: | ||||||||||
| 111 | |||||||||||
| 112 | =cut | ||||||||||
| 113 | |||||||||||
| 114 | =head2 false | ||||||||||
| 115 | |||||||||||
| 116 | false() (Bool) | ||||||||||
| 117 | |||||||||||
| 118 | The false function returns a falsy boolean value which is designed to be | ||||||||||
| 119 | practically indistinguishable from the conventional numerical C<0> value. This | ||||||||||
| 120 | function is always exported unless a routine of the same name already exists. | ||||||||||
| 121 | |||||||||||
| 122 | I<Since C<0.01>> | ||||||||||
| 123 | |||||||||||
| 124 | =over 4 | ||||||||||
| 125 | |||||||||||
| 126 | =item false example 1 | ||||||||||
| 127 | |||||||||||
| 128 | package main; | ||||||||||
| 129 | |||||||||||
| 130 | use Mars; | ||||||||||
| 131 | |||||||||||
| 132 | my $false = false; | ||||||||||
| 133 | |||||||||||
| 134 | # 0 | ||||||||||
| 135 | |||||||||||
| 136 | =back | ||||||||||
| 137 | |||||||||||
| 138 | =over 4 | ||||||||||
| 139 | |||||||||||
| 140 | =item false example 2 | ||||||||||
| 141 | |||||||||||
| 142 | package main; | ||||||||||
| 143 | |||||||||||
| 144 | use Mars; | ||||||||||
| 145 | |||||||||||
| 146 | my $true = !false; | ||||||||||
| 147 | |||||||||||
| 148 | # 1 | ||||||||||
| 149 | |||||||||||
| 150 | =back | ||||||||||
| 151 | |||||||||||
| 152 | =cut | ||||||||||
| 153 | |||||||||||
| 154 | =head2 true | ||||||||||
| 155 | |||||||||||
| 156 | true() (Bool) | ||||||||||
| 157 | |||||||||||
| 158 | The true function returns a truthy boolean value which is designed to be | ||||||||||
| 159 | practically indistinguishable from the conventional numerical C<1> value. This | ||||||||||
| 160 | function is always exported unless a routine of the same name already exists. | ||||||||||
| 161 | |||||||||||
| 162 | I<Since C<0.01>> | ||||||||||
| 163 | |||||||||||
| 164 | =over 4 | ||||||||||
| 165 | |||||||||||
| 166 | =item true example 1 | ||||||||||
| 167 | |||||||||||
| 168 | package main; | ||||||||||
| 169 | |||||||||||
| 170 | use Mars; | ||||||||||
| 171 | |||||||||||
| 172 | my $true = true; | ||||||||||
| 173 | |||||||||||
| 174 | # 1 | ||||||||||
| 175 | |||||||||||
| 176 | =back | ||||||||||
| 177 | |||||||||||
| 178 | =over 4 | ||||||||||
| 179 | |||||||||||
| 180 | =item true example 2 | ||||||||||
| 181 | |||||||||||
| 182 | package main; | ||||||||||
| 183 | |||||||||||
| 184 | use Mars; | ||||||||||
| 185 | |||||||||||
| 186 | my $false = !true; | ||||||||||
| 187 | |||||||||||
| 188 | # 0 | ||||||||||
| 189 | |||||||||||
| 190 | =back | ||||||||||
| 191 | |||||||||||
| 192 | =cut | ||||||||||
| 193 | |||||||||||
| 194 | =head1 AUTHORS | ||||||||||
| 195 | |||||||||||
| 196 | Awncorp, C<awncorp@cpan.org> | ||||||||||
| 197 | |||||||||||
| 198 | =cut | ||||||||||