line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Store::CA::Bag; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
366
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
2
|
use Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
185
|
use Catmandu::Sane; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
134
|
use Catmandu::CA::API; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
434
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with 'Catmandu::Bag'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has api => (is => 'lazy'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _build_api { |
16
|
0
|
|
|
0
|
|
|
my $self = shift; |
17
|
0
|
|
|
|
|
|
return Catmandu::CA::API->new( |
18
|
|
|
|
|
|
|
url => $self->store->url, |
19
|
|
|
|
|
|
|
username => $self->store->username, |
20
|
|
|
|
|
|
|
password => $self->store->password, |
21
|
|
|
|
|
|
|
lang => $self->store->lang, |
22
|
|
|
|
|
|
|
model => $self->store->model |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub generator { |
27
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
28
|
0
|
|
|
|
|
|
my $field_list = $self->store->_field_list; |
29
|
0
|
|
|
|
|
|
my $stack = $self->api->list($field_list)->{'results'}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
return sub { |
32
|
|
|
|
|
|
|
# Consume the stack here |
33
|
0
|
|
|
0
|
|
|
return pop @{$stack}; |
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub each { |
38
|
0
|
|
|
0
|
0
|
|
my ($self, $sub) = @_; |
39
|
0
|
|
|
|
|
|
my $n = 0; |
40
|
0
|
|
|
|
|
|
my $field_list = $self->store->_field_list; |
41
|
0
|
|
|
|
|
|
my $stack = $self->api->list($field_list)->{'results'}; |
42
|
0
|
|
|
|
|
|
while (my $data = pop @{$stack}) { |
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$sub->($data); |
44
|
0
|
|
|
|
|
|
$n++; |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
|
return $n; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub get { |
50
|
|
|
|
|
|
|
my ($self, $id) = @_; |
51
|
|
|
|
|
|
|
my $field_list = $self->store->_field_list; |
52
|
|
|
|
|
|
|
return $self->api->id($id, $field_list); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub add { |
56
|
|
|
|
|
|
|
my ($self, $data) = @_; |
57
|
|
|
|
|
|
|
return $self->api->add($data); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub update { |
61
|
0
|
|
|
0
|
0
|
|
my ($self, $id, $data) = @_; |
62
|
0
|
|
|
|
|
|
return $self->api->update($id, $data); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub delete { |
66
|
|
|
|
|
|
|
my ($self, $id) = @_; |
67
|
|
|
|
|
|
|
return $self->api->delete($id); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub delete_all { |
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
Catmandu::NotImplemented->throw( |
73
|
|
|
|
|
|
|
message => 'Deleting items from store not supported.' |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
__END__ |