| 1 | package Venus::Module; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.018; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | # IMPORTS | ||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||
| 10 | 21 | ▶ | sub import { | ||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=34 SCAR=35.7
| |||||||||||||||||||||||||||||||||||
| 11 | 21 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | 21 | my $from = caller; | |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 21 | require Venus::Core; | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||
| 21 | 21 | ▶ | @args = grep defined && !ref && /^[A-Za-z]/, @args; | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
defined $_ && !ref($_) && /^[A-Za-z]/u
defined $_ and not ref $_
MC/DC0%0/3
defined $_ && !ref($_) && /^[A-Za-z]/u
defined $_
not ref $_
/^[A-Za-z]/u
Truth table25%1/4
A and not(B) && C
A= defined $_B= not ref $_C= /^[A-Za-z]/u
| |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | 21 | ▶ | my %exports = map +($_,$_), @args ? @args : qw( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 24 | false | ||||||||||||||||||||||||||||||||||
| 25 | mixin | ||||||||||||||||||||||||||||||||||
| 26 | role | ||||||||||||||||||||||||||||||||||
| 27 | test | ||||||||||||||||||||||||||||||||||
| 28 | true | ||||||||||||||||||||||||||||||||||
| 29 | with | ||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | 21 | @{"${from}::ISA"} = 'Venus::Core'; | |||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | 21 | ▶ | if ($exports{"after"} && !*{"${from}::after"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$exports{"after"} and not *{"${from}::after";}{"CODE"}
MC/DC50%1/2
$exports{"after"} and not *{"${from}::after";}{"CODE"}
$exports{"after"}
not *{"${from}::after";}{"CODE"}
Truth table66%2/3
A and not(B)
A= $exports{"after"}B= not *{"${from}::after";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | *{"${from}::after"} = sub ($$) {require Venus; goto \&Venus::after}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||
| 37 | 21 | ▶ | if ($exports{"around"} && !*{"${from}::around"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$exports{"around"} and not *{"${from}::around";}{"CODE"}
MC/DC50%1/2
$exports{"around"} and not *{"${from}::around";}{"CODE"}
$exports{"around"}
not *{"${from}::around";}{"CODE"}
Truth table66%2/3
A and not(B)
A= $exports{"around"}B= not *{"${from}::around";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | *{"${from}::around"} = sub ($$) {require Venus; goto \&Venus::around}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||
| 40 | 21 | ▶ | if ($exports{"before"} && !*{"${from}::before"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$exports{"before"} and not *{"${from}::before";}{"CODE"}
MC/DC50%1/2
$exports{"before"} and not *{"${from}::before";}{"CODE"}
$exports{"before"}
not *{"${from}::before";}{"CODE"}
Truth table66%2/3
A and not(B)
A= $exports{"before"}B= not *{"${from}::before";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 41 | 1 | ▶ | *{"${from}::before"} = sub ($$) {require Venus; goto \&Venus::before}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||
| 43 | 21 | ▶ | if ($exports{"catch"} && !*{"${from}::catch"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$exports{"catch"} and not *{"${from}::catch";}{"CODE"}
MC/DC50%1/2
$exports{"catch"} and not *{"${from}::catch";}{"CODE"}
$exports{"catch"}
not *{"${from}::catch";}{"CODE"}
Truth table66%2/3
A and not(B)
A= $exports{"catch"}B= not *{"${from}::catch";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | *{"${from}::catch"} = sub (&) {require Venus; goto \&Venus::catch}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||
| 46 | 21 | ▶ | if ($exports{"error"} && !*{"${from}::error"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$exports{"error"} and not *{"${from}::error";}{"CODE"}
MC/DC50%1/2
$exports{"error"} and not *{"${from}::error";}{"CODE"}
$exports{"error"}
not *{"${from}::error";}{"CODE"}
Truth table66%2/3
A and not(B)
A= $exports{"error"}B= not *{"${from}::error";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | *{"${from}::error"} = sub (;$) {require Venus; goto \&Venus::error}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||
| 49 | 21 | ▶ | if (!*{"${from}::false"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 50 | 8 | ▶ | *{"${from}::false"} = sub {require Venus; Venus::false()}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ($exports{"fault"} && !*{"${from}::fault"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$exports{"fault"} and not *{"${from}::fault";}{"CODE"}
MC/DC0%0/2
$exports{"fault"} and not *{"${from}::fault";}{"CODE"}
$exports{"fault"}
not *{"${from}::fault";}{"CODE"}
Truth table33%1/3
A and not(B)
A= $exports{"fault"}B= not *{"${from}::fault";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | *{"${from}::fault"} = sub (;$) {require Venus; goto \&Venus::fault}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||
| 55 | 21 | ▶ | if ($exports{"handle"} && !*{"${from}::handle"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$exports{"handle"} and not *{"${from}::handle";}{"CODE"}
MC/DC50%1/2
$exports{"handle"} and not *{"${from}::handle";}{"CODE"}
$exports{"handle"}
not *{"${from}::handle";}{"CODE"}
Truth table66%2/3
A and not(B)
A= $exports{"handle"}B= not *{"${from}::handle";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | *{"${from}::handle"} = sub ($$) {require Venus; goto \&Venus::handle}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||
| 58 | 21 | ▶ | if ($exports{"hook"} && !*{"${from}::hook"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$exports{"hook"} and not *{"${from}::hook";}{"CODE"}
MC/DC50%1/2
$exports{"hook"} and not *{"${from}::hook";}{"CODE"}
$exports{"hook"}
not *{"${from}::hook";}{"CODE"}
Truth table66%2/3
A and not(B)
A= $exports{"hook"}B= not *{"${from}::hook";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | *{"${from}::hook"} = sub ($$$) {require Venus; goto \&Venus::hook}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||
| 61 | 21 | ▶ | if (!*{"${from}::import"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 62 | 3 | ▶ | *{"${from}::import"} = sub {my $target = caller; $_[0]->USE($target); $_[0]->IMPORT($target, @_)}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||
| 64 | 21 | ▶ | if ($exports{"raise"} && !*{"${from}::raise"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$exports{"raise"} and not *{"${from}::raise";}{"CODE"}
MC/DC50%1/2
$exports{"raise"} and not *{"${from}::raise";}{"CODE"}
$exports{"raise"}
not *{"${from}::raise";}{"CODE"}
Truth table66%2/3
A and not(B)
A= $exports{"raise"}B= not *{"${from}::raise";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | *{"${from}::raise"} = sub ($;$) {require Venus; goto \&Venus::raise}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||
| 67 | 21 | ▶ | if ($exports{"mixin"} && !*{"${from}::mixin"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$exports{"mixin"} and not *{"${from}::mixin";}{"CODE"}
MC/DC100%2/2
$exports{"mixin"} and not *{"${from}::mixin";}{"CODE"}
$exports{"mixin"}
not *{"${from}::mixin";}{"CODE"}
Truth table100%3/3
A and not(B)
A= $exports{"mixin"}B= not *{"${from}::mixin";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 68 | 3 | ▶ | *{"${from}::mixin"} = sub {@_ = ($from, @_); goto \&mixin}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||
| 70 | 21 | ▶ | if ($exports{"role"} && !*{"${from}::role"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$exports{"role"} and not *{"${from}::role";}{"CODE"}
MC/DC100%2/2
$exports{"role"} and not *{"${from}::role";}{"CODE"}
$exports{"role"}
not *{"${from}::role";}{"CODE"}
Truth table100%3/3
A and not(B)
A= $exports{"role"}B= not *{"${from}::role";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 71 | 3 | ▶ | *{"${from}::role"} = sub {@_ = ($from, @_); goto \&role}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||
| 73 | 21 | ▶ | if ($exports{"test"} && !*{"${from}::test"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$exports{"test"} and not *{"${from}::test";}{"CODE"}
MC/DC100%2/2
$exports{"test"} and not *{"${from}::test";}{"CODE"}
$exports{"test"}
not *{"${from}::test";}{"CODE"}
Truth table100%3/3
A and not(B)
A= $exports{"test"}B= not *{"${from}::test";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | *{"${from}::test"} = sub {@_ = ($from, @_); goto \&test}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||
| 76 | 21 | ▶ | if (!*{"${from}::true"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 77 | 8 | ▶ | *{"${from}::true"} = sub {require Venus; Venus::true()}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||
| 79 | 21 | ▶ | if (!*{"${from}::unimport"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | *{"${from}::unimport"} = sub {my $target = caller; $_[0]->UNIMPORT($target, @_)}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||
| 82 | 21 | ▶ | if ($exports{"with"} && !*{"${from}::with"}{"CODE"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$exports{"with"} and not *{"${from}::with";}{"CODE"}
MC/DC100%2/2
$exports{"with"} and not *{"${from}::with";}{"CODE"}
$exports{"with"}
not *{"${from}::with";}{"CODE"}
Truth table100%3/3
A and not(B)
A= $exports{"with"}B= not *{"${from}::with";}{"CODE"}
| |||||||||||||||||||||||||||||||||||
| 83 | 3 | ▶ | *{"${from}::with"} = sub {@_ = ($from, @_); goto \&test}; | ||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||
| 86 | 21 | ${"${from}::META"} = {}; | |||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | 21 | ${"${from}::@{[$from->METACACHE]}"} = undef; | |||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | 21 | return $self; | |||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||
| 93 | # ROUTINES | ||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | sub mixin { | ||||||||||||||||||||||||||||||||
|
Subroutine
mixin: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 96 | 2 | my ($from, @args) = @_; | |||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||
| 98 | 2 | $from->MIXIN(@args); | |||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||
| 100 | 2 | return $from; | |||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | sub role { | ||||||||||||||||||||||||||||||||
|
Subroutine
role: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 104 | 2 | my ($from, @args) = @_; | |||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||
| 106 | 2 | $from->ROLE(@args); | |||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | 2 | return $from; | |||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||
| 111 | 4 | ▶ | sub test { | ||||||||||||||||||||||||||||||||
|
Subroutine
test: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 112 | 4 | my ($from, @args) = @_; | |||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||
| 114 | 4 | $from->TEST(@args); | |||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||
| 116 | 3 | return $from; | |||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||
| 119 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||
| 123 | =head1 NAME | ||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||
| 125 | Venus::Module - Module Builder | ||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | =cut | ||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||
| 129 | =head1 ABSTRACT | ||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||
| 131 | Module Builder for Perl 5 | ||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||
| 133 | =cut | ||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | package MakeError; | ||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||
| 139 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||
| 141 | sub make_error { | ||||||||||||||||||||||||||||||||||
| 142 | require Venus::Error; | ||||||||||||||||||||||||||||||||||
| 143 | Venus::Error->new(@_); | ||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||
| 146 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 147 | # explicitly declare routines to be consumed | ||||||||||||||||||||||||||||||||||
| 148 | ['make_error'] | ||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | package main; | ||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||
| 153 | BEGIN { | ||||||||||||||||||||||||||||||||||
| 154 | MakeError->import; | ||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||
| 157 | my $error = make_error 'Oops'; | ||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||
| 159 | # bless({message => 'Oops'}, 'Venus::Error') | ||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||
| 161 | =cut | ||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||
| 165 | This package provides a package/module builder which when used causes the | ||||||||||||||||||||||||||||||||||
| 166 | consumer to inherit from L<Venus::Core> which provides lifecycle | ||||||||||||||||||||||||||||||||||
| 167 | L<hooks|Venus::Hook>. | ||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||
| 169 | =cut | ||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||
| 173 | This package provides the following functions: | ||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||
| 175 | =cut | ||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||
| 177 | =head2 after | ||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||
| 179 | after(string $name, coderef $code) (coderef) | ||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||
| 181 | The after function installs a method modifier that executes after the original | ||||||||||||||||||||||||||||||||||
| 182 | method, allowing you to perform actions after a method call. B<Note:> The | ||||||||||||||||||||||||||||||||||
| 183 | return value of the modifier routine is ignored; the wrapped method always | ||||||||||||||||||||||||||||||||||
| 184 | returns the value from the original method. Modifiers are executed in the order | ||||||||||||||||||||||||||||||||||
| 185 | they are stacked. This function is always exported unless a routine of the same | ||||||||||||||||||||||||||||||||||
| 186 | name already exists. | ||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||
| 188 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||
| 190 | =over 4 | ||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||
| 192 | =item after example 1 | ||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | package MakeError; | ||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||
| 196 | use Venus::Module 'after'; | ||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||
| 198 | our $EVENTS = []; | ||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||
| 200 | sub make_error { | ||||||||||||||||||||||||||||||||||
| 201 | require Venus::Error; | ||||||||||||||||||||||||||||||||||
| 202 | my $error = Venus::Error->new(@_); | ||||||||||||||||||||||||||||||||||
| 203 | push @{$EVENTS}, 'orig'; | ||||||||||||||||||||||||||||||||||
| 204 | $error | ||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||
| 207 | after 'make_error', sub { | ||||||||||||||||||||||||||||||||||
| 208 | push @{$EVENTS}, 'after'; | ||||||||||||||||||||||||||||||||||
| 209 | }; | ||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||
| 211 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 212 | # explicitly declare routines to be consumed | ||||||||||||||||||||||||||||||||||
| 213 | ['make_error'] | ||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||
| 216 | package main; | ||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | MakeError->import; | ||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||
| 220 | my $error = make_error 'Oops'; | ||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | # bless({message => 'Oops'}, 'Venus::Error') | ||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||
| 224 | =back | ||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | =cut | ||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||
| 228 | =head2 around | ||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | around(string $name, coderef $code) (coderef) | ||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||
| 232 | The around function installs a method modifier that wraps around the original | ||||||||||||||||||||||||||||||||||
| 233 | method. The callback provided will recieve the original routine as its first | ||||||||||||||||||||||||||||||||||
| 234 | argument. This function is always exported unless a routine of the same name | ||||||||||||||||||||||||||||||||||
| 235 | already exists. | ||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||
| 237 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||
| 239 | =over 4 | ||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||
| 241 | =item around example 1 | ||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | package MakeError; | ||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||
| 245 | use Venus::Module 'around'; | ||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||
| 247 | our $EVENTS = []; | ||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||
| 249 | sub make_error { | ||||||||||||||||||||||||||||||||||
| 250 | require Venus::Error; | ||||||||||||||||||||||||||||||||||
| 251 | my $error = Venus::Error->new(@_); | ||||||||||||||||||||||||||||||||||
| 252 | push @{$EVENTS}, 'orig'; | ||||||||||||||||||||||||||||||||||
| 253 | $error | ||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||
| 256 | around 'make_error', sub { | ||||||||||||||||||||||||||||||||||
| 257 | my ($orig, @args) = @_; | ||||||||||||||||||||||||||||||||||
| 258 | push @{$EVENTS}, 'before'; | ||||||||||||||||||||||||||||||||||
| 259 | my $result = $orig->(@args); | ||||||||||||||||||||||||||||||||||
| 260 | push @{$EVENTS}, 'after'; | ||||||||||||||||||||||||||||||||||
| 261 | $result | ||||||||||||||||||||||||||||||||||
| 262 | }; | ||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||
| 264 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 265 | # explicitly declare routines to be consumed | ||||||||||||||||||||||||||||||||||
| 266 | ['make_error'] | ||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||
| 269 | package main; | ||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||
| 271 | MakeError->import; | ||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||
| 273 | my $error = make_error 'Oops'; | ||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | # bless({message => 'Oops'}, 'Venus::Error') | ||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||
| 277 | =back | ||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||
| 279 | =cut | ||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||
| 281 | =head2 before | ||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||
| 283 | before(string $name, coderef $code) (coderef) | ||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||
| 285 | The before function installs a method modifier that executes before the | ||||||||||||||||||||||||||||||||||
| 286 | original method, allowing you to perform actions before a method call. B<Note:> | ||||||||||||||||||||||||||||||||||
| 287 | The return value of the modifier routine is ignored; the wrapped method always | ||||||||||||||||||||||||||||||||||
| 288 | returns the value from the original method. Modifiers are executed in the order | ||||||||||||||||||||||||||||||||||
| 289 | they are stacked. This function is always exported unless a routine of the same | ||||||||||||||||||||||||||||||||||
| 290 | name already exists. | ||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||
| 292 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||
| 294 | =over 4 | ||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||
| 296 | =item before example 1 | ||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||
| 298 | package MakeError; | ||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||
| 300 | use Venus::Module 'before'; | ||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||
| 302 | our $EVENTS = []; | ||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | sub make_error { | ||||||||||||||||||||||||||||||||||
| 305 | require Venus::Error; | ||||||||||||||||||||||||||||||||||
| 306 | my $error = Venus::Error->new(@_); | ||||||||||||||||||||||||||||||||||
| 307 | push @{$EVENTS}, 'orig'; | ||||||||||||||||||||||||||||||||||
| 308 | $error | ||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||
| 311 | before 'make_error', sub { | ||||||||||||||||||||||||||||||||||
| 312 | push @{$EVENTS}, 'before'; | ||||||||||||||||||||||||||||||||||
| 313 | }; | ||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||
| 315 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 316 | # explicitly declare routines to be consumed | ||||||||||||||||||||||||||||||||||
| 317 | ['make_error'] | ||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||
| 320 | package main; | ||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||
| 322 | MakeError->import; | ||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||
| 324 | my $error = make_error 'Oops'; | ||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||
| 326 | # bless({message => 'Oops'}, 'Venus::Error') | ||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||
| 328 | =back | ||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||
| 330 | =cut | ||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||
| 332 | =head2 catch | ||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||
| 334 | catch(coderef $block) (Venus::Error, any) | ||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||
| 336 | The catch function executes the code block trapping errors and returning the | ||||||||||||||||||||||||||||||||||
| 337 | caught exception in scalar context, and also returning the result as a second | ||||||||||||||||||||||||||||||||||
| 338 | argument in list context. This function isn't export unless requested. | ||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||
| 340 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||
| 342 | =over 4 | ||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||
| 344 | =item catch example 1 | ||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||
| 346 | package Example; | ||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||
| 348 | use Venus::Module 'catch'; | ||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||
| 350 | sub attempt { | ||||||||||||||||||||||||||||||||||
| 351 | catch {die}; | ||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||
| 354 | package main; | ||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||
| 356 | my $error = Example::attempt; | ||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||
| 358 | $error; | ||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||
| 360 | # "Died at ..." | ||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||
| 362 | =back | ||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||
| 364 | =cut | ||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||
| 366 | =head2 error | ||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||
| 368 | error(maybe[hashref] $args) (Venus::Error) | ||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||
| 370 | The error function throws a L<Venus::Error> exception object using the | ||||||||||||||||||||||||||||||||||
| 371 | exception object arguments provided. This function isn't export unless | ||||||||||||||||||||||||||||||||||
| 372 | requested. | ||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||
| 374 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||
| 376 | =over 4 | ||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||
| 378 | =item error example 1 | ||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||
| 380 | package Example; | ||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||
| 382 | use Venus::Module 'error'; | ||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||
| 384 | sub attempt { | ||||||||||||||||||||||||||||||||||
| 385 | error; | ||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||
| 388 | package main; | ||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||
| 390 | my $error = Example::attempt; | ||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||
| 392 | # bless({...}, 'Venus::Error') | ||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||
| 394 | =back | ||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||
| 396 | =cut | ||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||
| 398 | =head2 false | ||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||
| 400 | false() (boolean) | ||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||
| 402 | The false function returns a falsy boolean value which is designed to be | ||||||||||||||||||||||||||||||||||
| 403 | practically indistinguishable from the conventional numerical C<0> value. This | ||||||||||||||||||||||||||||||||||
| 404 | function is always exported unless a routine of the same name already exists. | ||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||
| 406 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||
| 408 | =over 4 | ||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||
| 410 | =item false example 1 | ||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||
| 412 | package Example; | ||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||
| 414 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||
| 416 | my $false = false; | ||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||
| 418 | # 0 | ||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||
| 420 | =back | ||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||
| 422 | =cut | ||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||
| 424 | =head2 handle | ||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||
| 426 | handle(string $name, coderef $code) (coderef) | ||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||
| 428 | The handle function installs a method modifier that wraps a method, providing | ||||||||||||||||||||||||||||||||||
| 429 | low-level control. The callback provided will recieve the original routine as | ||||||||||||||||||||||||||||||||||
| 430 | its first argument (or C<undef> if the source routine doesn't exist). This | ||||||||||||||||||||||||||||||||||
| 431 | function is always exported unless a routine of the same name already exists. | ||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||
| 433 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||
| 435 | =over 4 | ||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||
| 437 | =item handle example 1 | ||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||
| 439 | package MakeError; | ||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||
| 441 | use Venus::Module 'handle'; | ||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||
| 443 | our $EVENTS = []; | ||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||
| 445 | handle 'make_error', sub { | ||||||||||||||||||||||||||||||||||
| 446 | my ($orig, @args) = @_; | ||||||||||||||||||||||||||||||||||
| 447 | push @{$EVENTS}, 'before'; | ||||||||||||||||||||||||||||||||||
| 448 | my $result = $orig->(@args) if $orig; | ||||||||||||||||||||||||||||||||||
| 449 | push @{$EVENTS}, 'after'; | ||||||||||||||||||||||||||||||||||
| 450 | $result | ||||||||||||||||||||||||||||||||||
| 451 | }; | ||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||
| 453 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 454 | # explicitly declare routines to be consumed | ||||||||||||||||||||||||||||||||||
| 455 | ['make_error'] | ||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||
| 458 | package main; | ||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||
| 460 | MakeError->import; | ||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||
| 462 | my $error = make_error 'Oops'; | ||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||
| 464 | # bless({message => 'Oops'}, 'Venus::Error') | ||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||
| 466 | =back | ||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||
| 468 | =over 4 | ||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||
| 470 | =item handle example 2 | ||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||
| 472 | package MakeError; | ||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||
| 474 | use Venus::Module 'handle'; | ||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||
| 476 | our $EVENTS = []; | ||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||
| 478 | sub make_error { | ||||||||||||||||||||||||||||||||||
| 479 | require Venus::Error; | ||||||||||||||||||||||||||||||||||
| 480 | my $error = Venus::Error->new(@_); | ||||||||||||||||||||||||||||||||||
| 481 | push @{$EVENTS}, 'orig'; | ||||||||||||||||||||||||||||||||||
| 482 | $error | ||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||
| 485 | handle 'make_error', sub { | ||||||||||||||||||||||||||||||||||
| 486 | my ($orig, @args) = @_; | ||||||||||||||||||||||||||||||||||
| 487 | push @{$EVENTS}, 'before'; | ||||||||||||||||||||||||||||||||||
| 488 | my $result = $orig->(@args) if $orig; | ||||||||||||||||||||||||||||||||||
| 489 | push @{$EVENTS}, 'after'; | ||||||||||||||||||||||||||||||||||
| 490 | $result | ||||||||||||||||||||||||||||||||||
| 491 | }; | ||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||
| 493 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 494 | # explicitly declare routines to be consumed | ||||||||||||||||||||||||||||||||||
| 495 | ['make_error'] | ||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||
| 498 | package main; | ||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||
| 500 | MakeError->import; | ||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||
| 502 | my $error = make_error 'Oops'; | ||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||
| 504 | # bless({message => 'Oops'}, 'Venus::Error') | ||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||
| 506 | =back | ||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||
| 508 | =cut | ||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||
| 510 | =head2 hook | ||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||
| 512 | hook(string $type, string $name, coderef $code) (coderef) | ||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||
| 514 | The hook function installs a method modifier on a lifecycle hook method. The | ||||||||||||||||||||||||||||||||||
| 515 | first argument is the type of modifier desired, e.g., L</before>, L</after>, | ||||||||||||||||||||||||||||||||||
| 516 | L</around>, and the callback provided will recieve the original routine as its | ||||||||||||||||||||||||||||||||||
| 517 | first argument. This function is always exported unless a routine of the same | ||||||||||||||||||||||||||||||||||
| 518 | name already exists. | ||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||
| 520 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||
| 522 | =over 4 | ||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||
| 524 | =item hook example 1 | ||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||
| 526 | package MakeError; | ||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||
| 528 | use Venus::Module 'hook'; | ||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||
| 530 | our $EVENTS = []; | ||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||
| 532 | sub make_error { | ||||||||||||||||||||||||||||||||||
| 533 | require Venus::Error; | ||||||||||||||||||||||||||||||||||
| 534 | my $error = Venus::Error->new(@_); | ||||||||||||||||||||||||||||||||||
| 535 | push @{$EVENTS}, 'orig'; | ||||||||||||||||||||||||||||||||||
| 536 | $error | ||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||
| 539 | hook 'around', 'use', sub { | ||||||||||||||||||||||||||||||||||
| 540 | push @{$EVENTS}, 'use'; | ||||||||||||||||||||||||||||||||||
| 541 | }; | ||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||
| 543 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 544 | # explicitly declare routines to be consumed | ||||||||||||||||||||||||||||||||||
| 545 | ['make_error'] | ||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||
| 548 | package main; | ||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||
| 550 | MakeError->import; | ||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||
| 552 | my $error = make_error 'Oops'; | ||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||
| 554 | # bless({message => 'Oops'}, 'Venus::Error') | ||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||
| 556 | =back | ||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||
| 558 | =cut | ||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||
| 560 | =head2 mixin | ||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||
| 562 | mixin(string $name) (string) | ||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||
| 564 | The mixin function registers and consumes mixins for the calling package. This | ||||||||||||||||||||||||||||||||||
| 565 | function is always exported unless a routine of the same name already exists. | ||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||
| 567 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||
| 569 | =over 4 | ||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||
| 571 | =item mixin example 1 | ||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||
| 573 | package YesNo; | ||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||
| 575 | use Venus::Mixin; | ||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||
| 577 | sub no { | ||||||||||||||||||||||||||||||||||
| 578 | return 0; | ||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||
| 581 | sub yes { | ||||||||||||||||||||||||||||||||||
| 582 | return 1; | ||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||
| 585 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 586 | ['no', 'yes'] | ||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||
| 589 | package Answer; | ||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||
| 591 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||
| 593 | mixin 'YesNo'; | ||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||
| 595 | # "Answer" | ||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||
| 597 | =back | ||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||
| 599 | =over 4 | ||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||
| 601 | =item mixin example 2 | ||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||
| 603 | package YesNo; | ||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||
| 605 | use Venus::Mixin; | ||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||
| 607 | sub no { | ||||||||||||||||||||||||||||||||||
| 608 | return 0; | ||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||
| 611 | sub yes { | ||||||||||||||||||||||||||||||||||
| 612 | return 1; | ||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||
| 615 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 616 | ['no', 'yes'] | ||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||
| 619 | package Answer; | ||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||
| 621 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||
| 623 | mixin 'YesNo'; | ||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||
| 625 | sub no { | ||||||||||||||||||||||||||||||||||
| 626 | return [0]; | ||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||
| 629 | sub yes { | ||||||||||||||||||||||||||||||||||
| 630 | return [1]; | ||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||
| 633 | my $package = "Answer"; | ||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||
| 635 | # "Answer" | ||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||
| 637 | =back | ||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||
| 639 | =cut | ||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||
| 641 | =head2 raise | ||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||
| 643 | raise(string $class | tuple[string, string] $class, maybe[hashref] $args) (Venus::Error) | ||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||
| 645 | The raise function generates and throws a named exception object derived from | ||||||||||||||||||||||||||||||||||
| 646 | L<Venus::Error>, or provided base class, using the exception object arguments | ||||||||||||||||||||||||||||||||||
| 647 | provided. This function isn't export unless requested. | ||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||
| 649 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||
| 651 | =over 4 | ||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||
| 653 | =item raise example 1 | ||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||
| 655 | package Example; | ||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||
| 657 | use Venus::Module 'raise'; | ||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||
| 659 | sub attempt { | ||||||||||||||||||||||||||||||||||
| 660 | raise 'Example::Error'; | ||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||
| 663 | package main; | ||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||
| 665 | my $error = Example::attempt; | ||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||
| 667 | # bless({...}, 'Example::Error') | ||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||
| 669 | =back | ||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||
| 671 | =cut | ||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||
| 673 | =head2 role | ||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||
| 675 | role(string $name) (string) | ||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||
| 677 | The role function registers and consumes roles for the calling package. This | ||||||||||||||||||||||||||||||||||
| 678 | function is always exported unless a routine of the same name already exists. | ||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||
| 680 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||
| 682 | =over 4 | ||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||
| 684 | =item role example 1 | ||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||
| 686 | package Ability; | ||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||
| 688 | use Venus::Role; | ||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||
| 690 | sub action { | ||||||||||||||||||||||||||||||||||
| 691 | return; | ||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||
| 694 | package Example; | ||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||
| 696 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||
| 698 | role 'Ability'; | ||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||
| 700 | # "Example" | ||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||
| 702 | =back | ||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||
| 704 | =over 4 | ||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||
| 706 | =item role example 2 | ||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||
| 708 | package Ability; | ||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||
| 710 | use Venus::Role; | ||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||
| 712 | sub action { | ||||||||||||||||||||||||||||||||||
| 713 | return; | ||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||
| 716 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 717 | return ['action']; | ||||||||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||
| 720 | package Example; | ||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||
| 722 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||
| 724 | role 'Ability'; | ||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||
| 726 | # "Example" | ||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||
| 728 | =back | ||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||
| 730 | =cut | ||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||
| 732 | =head2 test | ||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||
| 734 | test(string $name) (string) | ||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||
| 736 | The test function registers and consumes roles for the calling package and | ||||||||||||||||||||||||||||||||||
| 737 | performs an L<"audit"|Venus::Core/AUDIT>, effectively allowing a role to act as | ||||||||||||||||||||||||||||||||||
| 738 | an interface. This function is always exported unless a routine of the same | ||||||||||||||||||||||||||||||||||
| 739 | name already exists. | ||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||
| 741 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||
| 743 | =over 4 | ||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||
| 745 | =item test example 1 | ||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||
| 747 | package Actual; | ||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||
| 749 | use Venus::Role; | ||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||
| 751 | package Example; | ||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||
| 753 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||
| 755 | test 'Actual'; | ||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||
| 757 | # "Example" | ||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||
| 759 | =back | ||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||
| 761 | =over 4 | ||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||
| 763 | =item test example 2 | ||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||
| 765 | package Actual; | ||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||
| 767 | use Venus::Role; | ||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||
| 769 | sub AUDIT { | ||||||||||||||||||||||||||||||||||
| 770 | die "Example is not an 'actual' thing" if $_[1]->isa('Example'); | ||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||
| 773 | package Example; | ||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||
| 775 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||
| 777 | test 'Actual'; | ||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||
| 779 | # "Example" | ||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||
| 781 | =back | ||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||
| 783 | =cut | ||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||
| 785 | =head2 true | ||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||
| 787 | true() (boolean) | ||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||
| 789 | The true function returns a truthy boolean value which is designed to be | ||||||||||||||||||||||||||||||||||
| 790 | practically indistinguishable from the conventional numerical C<1> value. This | ||||||||||||||||||||||||||||||||||
| 791 | function is always exported unless a routine of the same name already exists. | ||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||
| 793 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||
| 795 | =over 4 | ||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||
| 797 | =item true example 1 | ||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||
| 799 | package Example; | ||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||
| 801 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||
| 803 | my $true = true; | ||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||
| 805 | # 1 | ||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||
| 807 | =back | ||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||
| 809 | =over 4 | ||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||
| 811 | =item true example 2 | ||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||
| 813 | package Example; | ||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||
| 815 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||
| 817 | my $false = !true; | ||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||
| 819 | # 0 | ||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||
| 821 | =back | ||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||
| 823 | =cut | ||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||
| 825 | =head2 with | ||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||
| 827 | with(string $name) (string) | ||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||
| 829 | The with function registers and consumes roles for the calling package. This | ||||||||||||||||||||||||||||||||||
| 830 | function is an alias of the L</test> function and will perform an | ||||||||||||||||||||||||||||||||||
| 831 | L<"audit"|Venus::Core/AUDIT> if present. This function is always exported | ||||||||||||||||||||||||||||||||||
| 832 | unless a routine of the same name already exists. | ||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||
| 834 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||
| 836 | =over 4 | ||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||
| 838 | =item with example 1 | ||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||
| 840 | package Understanding; | ||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||
| 842 | use Venus::Role; | ||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||
| 844 | sub knowledge { | ||||||||||||||||||||||||||||||||||
| 845 | return; | ||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||
| 848 | package Example; | ||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||
| 850 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||
| 852 | with 'Understanding'; | ||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||
| 854 | # "Example" | ||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||
| 856 | =back | ||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||
| 858 | =over 4 | ||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||
| 860 | =item with example 2 | ||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||
| 862 | package Understanding; | ||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||
| 864 | use Venus::Role; | ||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||
| 866 | sub knowledge { | ||||||||||||||||||||||||||||||||||
| 867 | return; | ||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||
| 870 | sub EXPORT { | ||||||||||||||||||||||||||||||||||
| 871 | return ['knowledge']; | ||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||
| 874 | package Example; | ||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||
| 876 | use Venus::Module; | ||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||
| 878 | with 'Understanding'; | ||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||
| 880 | # "Example" | ||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||
| 882 | =back | ||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||
| 884 | =cut | ||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||
| 886 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||
| 888 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||
| 890 | =cut | ||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||
| 892 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||
| 894 | Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||
| 896 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||
| 897 | the terms of the Apache license version 2.0. | ||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||
| 899 | =cut | ||||||||||||||||||||||||||||||||||