| 1 | package WARC::Record::Stub; # -*- CPerl -*- | ||||||||||
| 2 | |||||||||||
| 3 | 27 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 27 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 27 | our @ISA = qw(WARC::Record::FromVolume); | |||||||||
| 7 | |||||||||||
| 8 | 27 | ▶ | use WARC; *WARC::Record::Stub::VERSION = \$WARC::VERSION; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 27 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 27 | require WARC::Record::FromVolume; | |||||||||
| 13 | |||||||||||
| 14 | # This implementation uses a hash as the underlying structure. | ||||||||||
| 15 | |||||||||||
| 16 | # Instances of this class carry only two keys: volume and offset. | ||||||||||
| 17 | |||||||||||
| 18 | # Other method calls result in loading the full object. | ||||||||||
| 19 | |||||||||||
| 20 | sub new { | ||||||||||
| 21 | 215 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 22 | 215 | my $volume = shift; | |||||||||
| 23 | 215 | my $offset = shift; | |||||||||
| 24 | |||||||||||
| 25 | 215 | ▶ | croak "unbalanced key/value pairs" if scalar @_ % 2; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | |||||||||||
| 27 | 214 | my $ob = {volume => $volume, offset => $offset, @_}; | |||||||||
| 28 | |||||||||||
| 29 | 214 | bless $ob, $class; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | sub _load_and_forward { | ||||||||||
| 33 | 186 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_load_and_forward: called CC=2 SCAR=6.9
| |||||||||||
| 34 | 186 | my $method = shift; | |||||||||
| 35 | |||||||||||
| 36 | 186 | my $new = _read WARC::Record::FromVolume ($self->volume, $self->offset); | |||||||||
| 37 | |||||||||||
| 38 | 186 | $self->{$_} = $new->{$_} for keys %$new; | |||||||||
| 39 | 186 | bless $self, ref $new; | |||||||||
| 40 | |||||||||||
| 41 | 186 | $self->$method(@_) | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | BEGIN { | ||||||||||
| 45 | 27 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 46 | 27 | ▶ | foreach my $sub (qw/ fields protocol next open_block replay open_payload /) | ||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||||||||||
| 47 | 162 | ▶ | { *{$sub} = sub { (shift)->_load_and_forward($sub => @_)} } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 27 | 1; | |||||||||
| 51 | __END__ | ||||||||||