Venus/Role/Tryable.pm

filter: Statementstmt 100% 18 / 18 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 92.8% 26 / 28 CC 2 SCAR 2.5
CC
2
Cov
95%
try
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Venus/Role/Doable.pm ↑ Summary Venus/Role/Boxable.pm »
1 package Venus::Role::Tryable;
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 try {
13 1947 ▶ my ($self, $callback, @args) = @_;
Subroutine try: called CC=2 SCAR=7.0
Pod documented
14  
15 1947 require Venus::Try;
16  
17 1947 my $try = Venus::Try->new(invocant => $self, arguments => [@args]);
18  
19 1947 ▶ return $try if !$callback;
Branch: 1 branch
BranchTrueFalseTotal
unless $callback 0 1947 1947
20  
21 1947 return $try->call($callback);
22 }
23  
24 # EXPORTS
25  
26 sub EXPORT {
27 62 ▶ ['try']
Subroutine EXPORT: called CC=1 SCAR=0.0
Pod undocumented
28 }
29  
30 61 1;
31  
32  
33  
34 =head1 NAME
35  
36 Venus::Role::Tryable - Tryable Role
37  
38 =cut
39  
40 =head1 ABSTRACT
41  
42 Tryable Role for Perl 5
43  
44 =cut
45  
46 =head1 SYNOPSIS
47  
48 package Example;
49  
50 use Venus::Class 'with';
51 use Venus 'raise';
52  
53 with 'Venus::Role::Tryable';
54  
55 sub test {
56 raise 'Example::Error';
57 }
58  
59 package main;
60  
61 my $example = Example->new;
62  
63 # $example->try('test');
64  
65 =cut
66  
67 =head1 DESCRIPTION
68  
69 This package modifies the consuming package and provides a mechanism for
70 handling potentially volatile routines.
71  
72 =cut
73  
74 =head1 METHODS
75  
76 This package provides the following methods:
77  
78 =cut
79  
80 =head2 try
81  
82 try(Str | CodeRef $method, Any @args) (Try)
83  
84 The try method returns a L<Venus::Try> object having the invocant, callback,
85 arguments pre-configured. This method supports dispatching, i.e. providing a
86 method name 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 try example 1
93  
94 package main;
95  
96 my $example = Example->new;
97  
98 my $try = $example->try('test');
99  
100 # my $value = $try->result;
101  
102 =back
103  
104 =cut
« Venus/Role/Doable.pm ↑ Summary Venus/Role/Boxable.pm »