blib/lib/Venus/Mixin.pm

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