line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
our $VERSION = '1.2018'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Moo::Role; |
5
|
1
|
|
|
1
|
|
629
|
use MooX::Aliases; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
1
|
|
|
1
|
|
281
|
use Package::Stash; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
7
|
1
|
|
|
1
|
|
330
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
8
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
my ($self) = @_; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
0
|
21
|
if ($self->store->does('Catmandu::Droppable')) { |
12
|
|
|
|
|
|
|
Role::Tiny->apply_roles_to_object($self->store, |
13
|
1
|
50
|
|
|
|
11
|
qw(Catmandu::Plugin::Readonly::Droppable)); |
14
|
1
|
|
|
|
|
33
|
} |
15
|
|
|
|
|
|
|
if ($self->does('Catmandu::Droppable')) { |
16
|
|
|
|
|
|
|
Role::Tiny->apply_roles_to_object($self, |
17
|
1
|
50
|
|
|
|
711
|
qw(Catmandu::Plugin::Readonly::Droppable)); |
18
|
1
|
|
|
|
|
27
|
} |
19
|
|
|
|
|
|
|
if ($self->does('Catmandu::Searchable')) { |
20
|
|
|
|
|
|
|
Role::Tiny->apply_roles_to_object($self, |
21
|
1
|
50
|
|
|
|
105
|
qw(Catmandu::Plugin::Readonly::Searchable)); |
22
|
0
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
around add => sub { |
26
|
|
|
|
|
|
|
my ($orig, $self, $data) = @_; |
27
|
|
|
|
|
|
|
my $pkg = ref($self); |
28
|
|
|
|
|
|
|
$self->log->warn("trying to add to readonly store"); |
29
|
|
|
|
|
|
|
my $err = Catmandu::NotImplemented->new("$pkg is readonly"); |
30
|
|
|
|
|
|
|
return undef, $err; |
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
around delete => sub { |
34
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
35
|
|
|
|
|
|
|
my $pkg = ref($self); |
36
|
|
|
|
|
|
|
$self->log->warn("trying to delete from readonly store"); |
37
|
|
|
|
|
|
|
my $err = Catmandu::NotImplemented->new("$pkg is readonly"); |
38
|
|
|
|
|
|
|
return undef, $err; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
around delete_all => sub { |
42
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
43
|
|
|
|
|
|
|
my $pkg = ref($self); |
44
|
|
|
|
|
|
|
$self->log->warn("trying to delete_all on readonly store"); |
45
|
|
|
|
|
|
|
my $err = Catmandu::NotImplemented->new("$pkg is readonly"); |
46
|
|
|
|
|
|
|
return undef, $err; |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Catmandu::Plugin::Readonly - Make stores or bags read-only |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$ cat catmandu.yml |
61
|
|
|
|
|
|
|
--- |
62
|
|
|
|
|
|
|
store: |
63
|
|
|
|
|
|
|
test: |
64
|
|
|
|
|
|
|
package: MongoDB |
65
|
|
|
|
|
|
|
options: |
66
|
|
|
|
|
|
|
default_plugins: [ 'Readonly'] |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The Catmandu::Plugin::Readonly will transform a Catmandu::Store or a Catmandu::Bag |
71
|
|
|
|
|
|
|
in read-only mode: all writes, deletes and drops will be ignored. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This command will work on L<Catmandu::Store> |
74
|
|
|
|
|
|
|
implementations. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SEE ALSO |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L<Catmandu::Store>, L<Catmandu::Bag> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |