Slick/Util.pm

filter: Statementstmt 75.0% 15 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 100% 2 / 2 totaltotal 78.5% 22 / 28 CC 3 SCAR 9.2
CC
3
Cov
75%
four_digit_number
6.0
monkey_patch
2.0
BEGIN
1.0
CRAP 2.5
« Slick/DatabaseExecutor.pm ↑ Summary Slick/Error.pm »
1 package Slick::Util;
2  
3 1 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Sub::Util qw(set_subname);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # Generate a 4 digit number for request tracing
8 0 ▶sub four_digit_number {
Subroutine four_digit_number: not called CC=2 SCAR=17.9
Pod documented
9 0 my @chars = ( 1 .. 9 );
10  
11 0 my $n = '';
12 0 for ( 1 .. 4 ) {
13 0 $n .= $chars[ int rand @chars ];
14 }
15  
16 0 return $n;
17 }
18  
19 ## no critic qw(TestingAndDebugging::ProhibitNoStrict TestingAndDebugging::ProhibitNoWarnings Subroutines::RequireFinalReturn)
20 7 ▶sub monkey_patch {
Subroutine monkey_patch: called CC=2 SCAR=6.9
Pod documented
21  
22 # Credits to: https://github.com/mojolicious/mojo/blob/1343054b7f5c3e8c70c073e28c7ac65ab4008723/lib/Mojo/Util.pm#L200C1-L206C2
23  
24 7 my ( $class, %patch ) = @_;
25 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 7 *{"${class}::$_"} = set_subname( "${class}::$_", $patch{$_} )
28 7 for keys %patch;
29 }
30  
31 1 1;
32  
33 =encoding utf8
34  
35 =head1 NAME
36  
37 Slick::EventHandler
38  
39 =head1 SYNOPSIS
40  
41 A utility module that provides a few small useful tid-bits.
42  
43 =head1 API
44  
45 =head2 four_digit_number
46  
47 A method that returns a four-digit number.
48  
49 =head2 monkey_patch
50  
51 Patches a sub-routine onto a package as a method.
52  
53 =over2
54  
55 =item * L<Slick>
56  
57 =item * L<Slick::Context>
58  
59 =item * L<Slick::Database>
60  
61 =item * L<Slick::DatabaseExecutor>
62  
63 =item * L<Slick::DatabaseExecutor::MySQL>
64  
65 =item * L<Slick::DatabaseExecutor::Pg>
66  
67 =item * L<Slick::EventHandler>
68  
69 =item * L<Slick::Events>
70  
71 =item * L<Slick::Methods>
72  
73 =item * L<Slick::RouteMap>
74  
75 =item * L<Slick::Util>
76  
77 =back
78  
79 =cut
« Slick/DatabaseExecutor.pm ↑ Summary Slick/Error.pm »