line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Path; |
2
|
|
|
|
|
|
|
|
3
|
95
|
|
|
95
|
|
50171
|
use Catmandu::Sane; |
|
95
|
|
|
|
|
250
|
|
|
95
|
|
|
|
|
651
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
95
|
|
|
95
|
|
750
|
use Catmandu::Util qw(is_array_ref is_code_ref); |
|
95
|
|
|
|
|
277
|
|
|
95
|
|
|
|
|
4935
|
|
8
|
95
|
|
|
95
|
|
607
|
use Moo::Role; |
|
95
|
|
|
|
|
238
|
|
|
95
|
|
|
|
|
728
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has path => (is => 'ro', required => 1); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
requires 'getter'; |
13
|
|
|
|
|
|
|
requires 'setter'; |
14
|
|
|
|
|
|
|
requires 'creator'; |
15
|
|
|
|
|
|
|
requires 'updater'; |
16
|
|
|
|
|
|
|
requires 'deleter'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
around creator => sub { |
19
|
|
|
|
|
|
|
my $orig = shift; |
20
|
|
|
|
|
|
|
my $self = shift; |
21
|
|
|
|
|
|
|
my %opts = @_ == 1 ? (value => $_[0]) : @_; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$orig->($self, %opts); |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
around updater => sub { |
27
|
|
|
|
|
|
|
my $orig = shift; |
28
|
|
|
|
|
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
my %opts = @_ == 1 ? (value => $_[0]) : @_; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
for my $key (keys %opts) { |
32
|
|
|
|
|
|
|
my $val = $opts{$key}; |
33
|
|
|
|
|
|
|
next unless $key =~ s/^if_//; |
34
|
|
|
|
|
|
|
push @{$opts{if} ||= []}, $key, $val; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
if (my $tests = $opts{if}) { |
38
|
|
|
|
|
|
|
for (my $i = 0; $i < @$tests; $i += 2) { |
39
|
|
|
|
|
|
|
my $test = $tests->[$i]; |
40
|
|
|
|
|
|
|
$test = [$test] unless is_array_ref($test); |
41
|
|
|
|
|
|
|
$tests->[$i] |
42
|
|
|
|
|
|
|
= [map {is_code_ref($_) ? $_ : Catmandu::Util->can("is_$_")} |
43
|
|
|
|
|
|
|
@$test]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$orig->($self, %opts); |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Catmandu::Path - Base role for Catmandu path implementations |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SEE ALSO |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
L<Catmandu::Path::simple>. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |