| 1 | package Venus::Role::Doable; | ||||||||||||||||||||
| 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 'with'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | # METHODS | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 532 | ▶ | sub do { | ||||||||||||||||||
|
Subroutine
do: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 15 | 532 | my ($self, $code, @args) = @_; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 532 | ▶ | $code ||= sub{}; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
$code ||= sub {
}
MC/DC0%0/2
$code ||= sub {
}
$code
sub {
}
Truth table33%1/3
A ||= B
A= $codeB= sub {
}
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 532 | local $_ = $self; | |||||||||||||||||||
| 20 | 532 | $self->$code(@args); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 532 | return $self; | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | # EXPORTS | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 120 | ▶ | sub EXPORT { | ||||||||||||||||||
|
Subroutine
EXPORT: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 28 | 120 | ['do'] | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 119 | 1; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | =head1 NAME | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | Venus::Role::Doable - Doable Role | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | =head1 ABSTRACT | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | Doable Role for Perl 5 | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =head1 SYNOPSIS | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | package Example; | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | use Venus::Class; | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | with 'Venus::Role::Doable'; | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | attr 'time'; | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | sub execute { | ||||||||||||||||||||
| 58 | return; | ||||||||||||||||||||
| 59 | } | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | package main; | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | my $example = Example->new; | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | # $example->do(time => time)->execute; | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =cut | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =head1 DESCRIPTION | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | This package modifies the consuming package and provides methods for chaining | ||||||||||||||||||||
| 72 | any chainable and non-chainable methods (by ignoring their return values). | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head1 METHODS | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | This package provides the following methods: | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head2 do | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | do(string | coderef $method, any @args) (object) | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | The do method dispatches the method call or executes the callback and returns | ||||||||||||||||||||
| 87 | the invocant. This method supports dispatching, i.e. providing a method name | ||||||||||||||||||||
| 88 | and arguments whose return value will be acted on by this method. | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | I<Since C<0.01>> | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | =over 4 | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | =item do example 1 | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | package main; | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | my $example = Example->new; | ||||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | $example = $example->do(time => time); | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | # bless({ time => 0000000000 }, "Example") | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | # $example->execute; | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | =back | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | =head1 AUTHORS | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | =cut | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | =head1 LICENSE | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||
| 121 | the terms of the Apache license version 2.0. | ||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | =cut | ||||||||||||||||||||