| 1 | package Venus::Role::Explainable; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 119 | ▶ | use 5.018; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 119 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 119 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | # IMPORTS | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 119 | ▶ | use Venus::Role 'fault'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | # AUDITS | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 288 | ▶ | sub AUDIT { | ||||||||||||||||||
|
Subroutine
AUDIT: called CC=3 SCAR=12.7
Pod
undocumented
| |||||||||||||||||||||
| 15 | 288 | my ($self, $from) = @_; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 288 | ▶ | my $name = ref $self || $self; | ||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 288 | ▶ | if (!$from->can('explain')) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | 0 | fault "${from} requires 'explain' to consume ${name}"; | |||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 288 | return $self; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 119 | 1; | |||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | Venus::Role::Explainable - Explainable Role | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | =head1 ABSTRACT | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | Explainable Role for Perl 5 | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =cut | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =head1 SYNOPSIS | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | package Example; | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | use Venus::Class; | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | attr 'test'; | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | sub explain { | ||||||||||||||||||||
| 51 | "okay" | ||||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | with 'Venus::Role::Explainable'; | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | package main; | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | my $example = Example->new(test => 123); | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | # $example->explain; | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =cut | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | =head1 DESCRIPTION | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | This package modifies the consuming package and provides methods for making the | ||||||||||||||||||||
| 67 | object stringifiable. | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =head1 METHODS | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | This package provides the following methods: | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | =head2 explain | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | explain() (any) | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | The explain method takes no arguments and returns the value to be used in | ||||||||||||||||||||
| 82 | stringification operations. | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | I<Since C<0.01>> | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | =over 4 | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | =item explain example 1 | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | package main; | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | my $example = Example->new(test => 123); | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | my $explain = $example->explain; | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | # "okay" | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | =back | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | =cut | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | =head1 AUTHORS | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | =head1 LICENSE | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||
| 113 | the terms of the Apache license version 2.0. | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | =cut | ||||||||||||||||||||