line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package YAML::Perl::Processor; |
2
|
16
|
|
|
16
|
|
2986
|
use YAML::Perl::Base -base; |
|
16
|
|
|
|
|
33
|
|
|
16
|
|
|
|
|
138
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
field 'opened' => 0; |
5
|
|
|
|
|
|
|
field 'closed' => 0; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Every class in the stack should have an open and close method. |
8
|
|
|
|
|
|
|
# They should only allow an object to be opened once. |
9
|
|
|
|
|
|
|
sub open { |
10
|
243
|
|
|
243
|
0
|
511
|
my $self = shift; |
11
|
243
|
|
|
|
|
595
|
my $class = ref($self); |
12
|
243
|
50
|
|
|
|
6818
|
throw "Can't open an already opened $class object" |
13
|
|
|
|
|
|
|
if $self->opened; |
14
|
243
|
50
|
|
|
|
6309
|
throw "Can't open an already closed $class object" |
15
|
|
|
|
|
|
|
if $self->closed; |
16
|
243
|
|
|
|
|
15649
|
my $next_layer = $self->next_layer; |
17
|
243
|
100
|
|
|
|
5192
|
$self->$next_layer->open(@_) |
18
|
|
|
|
|
|
|
if $next_layer; |
19
|
243
|
|
|
|
|
6110
|
$self->opened(1); |
20
|
243
|
|
|
|
|
617
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub close { |
24
|
38
|
|
|
38
|
0
|
63
|
my $self = shift; |
25
|
38
|
|
|
|
|
71
|
my $class = ref($self); |
26
|
38
|
50
|
|
|
|
1234
|
throw "Can't close an unopened $class object" |
27
|
|
|
|
|
|
|
unless $self->opened; |
28
|
38
|
50
|
|
|
|
968
|
throw "Can't close an already closed $class object" |
29
|
|
|
|
|
|
|
if $self->closed; |
30
|
38
|
|
|
|
|
984
|
my $next_layer = $self->next_layer; |
31
|
38
|
100
|
|
|
|
908
|
$self->$next_layer->close(@_) |
32
|
|
|
|
|
|
|
if $next_layer; |
33
|
38
|
|
|
|
|
874
|
$self->closed(1); |
34
|
38
|
|
|
|
|
74
|
return 1; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |