line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
2
|
|
|
2
|
|
87731
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
12
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
2
|
|
|
2
|
|
14
|
use Hash::Merge::Simple qw(merge); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
8
|
2
|
|
|
2
|
|
640
|
use namespace::clean; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
131
|
|
9
|
2
|
|
|
2
|
|
11
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Bag'; |
11
|
|
|
|
|
|
|
with 'Catmandu::Droppable'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my ($self) = @_; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
0
|
6
|
# 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
|
|
|
|
|
6
|
my $bag = $store->bag($self->name); |
20
|
4
|
|
|
|
|
9
|
$gen = $bag ? $bag->generator : undef; |
|
4
|
|
|
|
|
49
|
|
21
|
4
|
|
|
|
|
14
|
last if defined($gen); |
22
|
4
|
50
|
|
|
|
16
|
} |
23
|
4
|
50
|
|
|
|
10
|
|
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
|
|
|
|
13
|
}; |
31
|
3
|
|
|
|
|
22
|
} |
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
|
4
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
} |
99
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
100
|
2
|
|
|
|
|
8
|
my ($self) = @_; |
101
|
2
|
50
|
33
|
|
|
13
|
|
102
|
|
|
|
|
|
|
# By default try to commit the data to all the stores |
103
|
|
|
|
|
|
|
|
104
|
1
|
|
|
|
|
3
|
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 |