line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
2
|
|
|
2
|
|
88318
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
12
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
2
|
|
|
2
|
|
12
|
use Hash::Merge::Simple qw(merge); |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
9
|
|
8
|
2
|
|
|
2
|
|
644
|
use namespace::clean; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
117
|
|
9
|
2
|
|
|
2
|
|
10
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Bag'; |
11
|
|
|
|
|
|
|
with 'Catmandu::Droppable'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
0
|
7
|
# Loop of all stores and find the first one that implements the bag |
16
|
|
|
|
|
|
|
# and can create a generator |
17
|
|
|
|
|
|
|
my $gen; |
18
|
|
|
|
|
|
|
for my $store (@{$self->store->stores}) { |
19
|
4
|
|
|
|
|
7
|
my $bag = $store->bag($self->name); |
20
|
4
|
|
|
|
|
5
|
$gen = $bag ? $bag->generator : undef; |
|
4
|
|
|
|
|
14
|
|
21
|
4
|
|
|
|
|
13
|
last if defined($gen); |
22
|
4
|
50
|
|
|
|
14
|
} |
23
|
4
|
50
|
|
|
|
11
|
|
24
|
|
|
|
|
|
|
return undef unless $gen; |
25
|
|
|
|
|
|
|
|
26
|
4
|
50
|
|
|
|
8
|
sub { |
27
|
|
|
|
|
|
|
my $item = $gen->(); |
28
|
|
|
|
|
|
|
return undef unless $item; |
29
|
6
|
|
|
6
|
|
11
|
return $item; |
30
|
6
|
100
|
|
|
|
15
|
}; |
31
|
3
|
|
|
|
|
14
|
} |
32
|
4
|
|
|
|
|
14
|
|
33
|
|
|
|
|
|
|
my ($self, $id) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Loop over all the bags and merge the results of the records found |
36
|
|
|
|
|
|
|
# Required in case of Store/FileStore combinations where each part |
37
|
|
|
|
|
|
|
# can contain different metadata |
38
|
|
|
|
|
|
|
my $found = 0; |
39
|
|
|
|
|
|
|
my $result = {}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
for my $store (@{$self->store->stores}) { |
42
|
|
|
|
|
|
|
my $bag = $store->bag($self->name); |
43
|
|
|
|
|
|
|
my $item = $bag ? $bag->get($id) : undef; |
44
|
|
|
|
|
|
|
if ($item) { |
45
|
|
|
|
|
|
|
$found = 1; |
46
|
|
|
|
|
|
|
$result = merge $result , $item; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
return $found ? $result : undef; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my ($self, $data) = @_; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# By default try to add the data to all the stores |
56
|
|
|
|
|
|
|
for my $store (@{$self->store->stores}) { |
57
|
|
|
|
|
|
|
my $bag = $store->bag($self->name); |
58
|
|
|
|
|
|
|
$bag->add($data) if $bag; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my ($self, $id) = @_; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# By default try to delete the data from all the stores |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
for my $store (@{$self->store->stores}) { |
69
|
|
|
|
|
|
|
my $bag = $store->bag($self->name); |
70
|
|
|
|
|
|
|
$bag->delete($id) if $bag; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my ($self) = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# By default try to drop the data from all the stores |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
for my $store (@{$self->store->stores}) { |
81
|
|
|
|
|
|
|
my $bag = $store->bag($self->name); |
82
|
|
|
|
|
|
|
$bag->delete_all if $bag; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my ($self) = @_; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# By default try to delete the data from all the stores |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
for my $store (@{$self->store->stores}) { |
93
|
|
|
|
|
|
|
my $bag = $store->bag($self->name); |
94
|
|
|
|
|
|
|
$bag->drop if $bag && $bag->does('Catmandu::Droppable'); |
95
|
1
|
|
|
1
|
0
|
3
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
} |
99
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
100
|
2
|
|
|
|
|
6
|
my ($self) = @_; |
101
|
2
|
50
|
33
|
|
|
18
|
|
102
|
|
|
|
|
|
|
# By default try to commit the data to all the stores |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
2
|
for my $store (@{$self->store->stores}) { |
105
|
|
|
|
|
|
|
my $bag = $store->bag($self->name); |
106
|
|
|
|
|
|
|
$bag->commit if $bag; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
1; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=pod |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 NAME |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Catmandu::Store::Multi::Bag - Bag implementation for the Multi store |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |