| 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
|
|
872
|
use strict; |
|
|
107
|
|
|
|
|
301
|
|
|
|
107
|
|
|
|
|
5032
|
|
|
5
|
107
|
|
|
107
|
|
616
|
use warnings; |
|
|
107
|
|
|
|
|
230
|
|
|
|
107
|
|
|
|
|
6168
|
|
|
6
|
107
|
|
|
107
|
|
654
|
use feature ':5.16'; |
|
|
107
|
|
|
|
|
218
|
|
|
|
107
|
|
|
|
|
18227
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
107
|
|
|
107
|
|
765
|
use Exporter qw(import); |
|
|
107
|
|
|
|
|
481
|
|
|
|
107
|
|
|
|
|
5503
|
|
|
9
|
107
|
|
|
107
|
|
59590
|
use Sub::Util qw(set_subname); |
|
|
107
|
|
|
|
|
43880
|
|
|
|
107
|
|
|
|
|
26135
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = (qw(class_to_path monkey_patch)); |
|
12
|
|
|
|
|
|
|
|
|
13
|
887
|
|
|
887
|
0
|
792993
|
sub class_to_path { join '.', join('/', split(/::|'/, shift)), 'pm' } |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub monkey_patch { |
|
16
|
57679
|
|
|
57679
|
0
|
187565
|
my ($class, %patch) = @_; |
|
17
|
107
|
|
|
107
|
|
815
|
no strict 'refs'; |
|
|
107
|
|
|
|
|
189
|
|
|
|
107
|
|
|
|
|
5078
|
|
|
18
|
107
|
|
|
107
|
|
519
|
no warnings 'redefine'; |
|
|
107
|
|
|
|
|
234
|
|
|
|
107
|
|
|
|
|
20641
|
|
|
19
|
57679
|
|
|
|
|
428681
|
*{"${class}::$_"} = set_subname("${class}::$_", $patch{$_}) for keys %patch; |
|
|
57912
|
|
|
|
|
2866037
|
|
|
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 |