Venus/Role/Doable.pm

filter: Statementstmt 100% 18 / 18 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 50.0% 1 / 2 totaltotal 81.2% 26 / 32 CC 2 SCAR 2.5
CC
2
Cov
90%
do
2.1
__ANON__
1.1
BEGIN
1.0
CRAP 1.3
« Venus/Kind/Value.pm ↑ Summary Venus/Role/Tryable.pm »
1 package Venus::Role::Doable;
2  
3 61 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 61 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 61 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 61 ▶use Venus::Role 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # METHODS
11  
12 sub do {
13 7 ▶ my ($self, $code, @args) = @_;
Subroutine do: called CC=2 SCAR=7.2
Pod documented
14  
15 7 ▶ $code ||= sub{};
Subroutine __ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
$code ||= sub { }
l!l&&r!l&&!r
700
MC/DC0%0/2
$code ||= sub { }
$code sub { }
Truth table33%1/3
A ||= B
A= $codeB= sub { }
ABresult
1X1
011
000
16  
17 7 local $_ = $self;
18 7 $self->$code(@args);
19  
20 7 return $self;
21 }
22  
23 # EXPORTS
24  
25 sub EXPORT {
26 62 ▶ ['do']
Subroutine EXPORT: called CC=1 SCAR=0.0
Pod undocumented
27 }
28  
29 61 1;
30  
31  
32  
33 =head1 NAME
34  
35 Venus::Role::Doable - Doable Role
36  
37 =cut
38  
39 =head1 ABSTRACT
40  
41 Doable Role for Perl 5
42  
43 =cut
44  
45 =head1 SYNOPSIS
46  
47 package Example;
48  
49 use Venus::Class;
50  
51 with 'Venus::Role::Doable';
52  
53 attr 'time';
54  
55 sub execute {
56 return;
57 }
58  
59 package main;
60  
61 my $example = Example->new;
62  
63 # $example->do(time => time)->execute;
64  
65 =cut
66  
67 =head1 DESCRIPTION
68  
69 This package modifies the consuming package and provides methods for chaining
70 any chainable and non-chainable methods (by ignoring their return values).
71  
72 =cut
73  
74 =head1 METHODS
75  
76 This package provides the following methods:
77  
78 =cut
79  
80 =head2 do
81  
82 do(Str | CodeRef $method, Any @args) (Self)
83  
84 The do method dispatches the method call or executes the callback and returns
85 the invocant. This method supports dispatching, i.e. providing a method name
86 and arguments whose return value will be acted on by this method.
87  
88 I<Since C<0.01>>
89  
90 =over 4
91  
92 =item do example 1
93  
94 package main;
95  
96 my $example = Example->new;
97  
98 $example = $example->do(time => time);
99  
100 # bless({ time => 0000000000 }, "Example")
101  
102 # $example->execute;
103  
104 =back
105  
106 =cut
« Venus/Kind/Value.pm ↑ Summary Venus/Role/Tryable.pm »