| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mojo::BaseUtil; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Only using pure Perl as the only purpose of this module is to break a circular dependency involving Mojo::Base |
|
4
|
107
|
|
|
107
|
|
577
|
use strict; |
|
|
107
|
|
|
|
|
204
|
|
|
|
107
|
|
|
|
|
3763
|
|
|
5
|
107
|
|
|
107
|
|
448
|
use warnings; |
|
|
107
|
|
|
|
|
163
|
|
|
|
107
|
|
|
|
|
4648
|
|
|
6
|
107
|
|
|
107
|
|
439
|
use feature ':5.16'; |
|
|
107
|
|
|
|
|
165
|
|
|
|
107
|
|
|
|
|
12112
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
107
|
|
|
107
|
|
539
|
use Exporter qw(import); |
|
|
107
|
|
|
|
|
162
|
|
|
|
107
|
|
|
|
|
3858
|
|
|
9
|
107
|
|
|
107
|
|
44659
|
use Sub::Util qw(set_subname); |
|
|
107
|
|
|
|
|
27292
|
|
|
|
107
|
|
|
|
|
17096
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = (qw(class_to_path monkey_patch)); |
|
12
|
|
|
|
|
|
|
|
|
13
|
889
|
|
|
889
|
0
|
500890
|
sub class_to_path { join '.', join('/', split(/::|'/, shift)), 'pm' } |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub monkey_patch { |
|
16
|
57680
|
|
|
57680
|
0
|
132659
|
my ($class, %patch) = @_; |
|
17
|
107
|
|
|
107
|
|
680
|
no strict 'refs'; |
|
|
107
|
|
|
|
|
146
|
|
|
|
107
|
|
|
|
|
3300
|
|
|
18
|
107
|
|
|
107
|
|
361
|
no warnings 'redefine'; |
|
|
107
|
|
|
|
|
144
|
|
|
|
107
|
|
|
|
|
14413
|
|
|
19
|
57680
|
|
|
|
|
240287
|
*{"${class}::$_"} = set_subname("${class}::$_", $patch{$_}) for keys %patch; |
|
|
57913
|
|
|
|
|
1664093
|
|
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=encoding utf8 |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Mojo::BaseUtil - Common utility functions used in Mojo::Base, re-exported in Mojo::Util |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Mojo::BaseUtil qw(class_to_path monkey_patch); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $path = class_to_path 'Foo::Bar'; |
|
35
|
|
|
|
|
|
|
monkey_patch 'MyApp', foo => sub { say 'Foo!' }; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
L provides functions to both L and L, so that C does not have to |
|
40
|
|
|
|
|
|
|
load the rest of L, while preventing a circular dependency. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
L, L, L. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |