| 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
|
|
820
|
use strict; |
|
|
107
|
|
|
|
|
290
|
|
|
|
107
|
|
|
|
|
4692
|
|
|
5
|
107
|
|
|
107
|
|
565
|
use warnings; |
|
|
107
|
|
|
|
|
195
|
|
|
|
107
|
|
|
|
|
6143
|
|
|
6
|
107
|
|
|
107
|
|
607
|
use feature ':5.16'; |
|
|
107
|
|
|
|
|
222
|
|
|
|
107
|
|
|
|
|
16853
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
107
|
|
|
107
|
|
703
|
use Exporter qw(import); |
|
|
107
|
|
|
|
|
251
|
|
|
|
107
|
|
|
|
|
5350
|
|
|
9
|
107
|
|
|
107
|
|
57952
|
use Sub::Util qw(set_subname); |
|
|
107
|
|
|
|
|
37825
|
|
|
|
107
|
|
|
|
|
25688
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = (qw(class_to_path monkey_patch)); |
|
12
|
|
|
|
|
|
|
|
|
13
|
887
|
|
|
887
|
0
|
775781
|
sub class_to_path { join '.', join('/', split(/::|'/, shift)), 'pm' } |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub monkey_patch { |
|
16
|
57679
|
|
|
57679
|
0
|
190158
|
my ($class, %patch) = @_; |
|
17
|
107
|
|
|
107
|
|
809
|
no strict 'refs'; |
|
|
107
|
|
|
|
|
195
|
|
|
|
107
|
|
|
|
|
4797
|
|
|
18
|
107
|
|
|
107
|
|
518
|
no warnings 'redefine'; |
|
|
107
|
|
|
|
|
195
|
|
|
|
107
|
|
|
|
|
19393
|
|
|
19
|
57679
|
|
|
|
|
400933
|
*{"${class}::$_"} = set_subname("${class}::$_", $patch{$_}) for keys %patch; |
|
|
57912
|
|
|
|
|
2793751
|
|
|
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 |