| 1 | =head1 NAME | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | Cache::File::Handle - wrapper for IO::File to use in Cache::File implementation | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =head1 DESCRIPTION | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | This module implements a derived class of IO::File that allows callback on | ||||||||||||||||||||
| 8 | close. It is for use by Cache::File and should not be used directly. | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | =cut | ||||||||||||||||||||
| 11 | package Cache::File::Handle; | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 1 | require 5.006; | |||||||||||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 1 | ▶ | use IO::File; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 1 | our @ISA = qw(IO::File); | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 22 | 0 | my $proto = shift; | |||||||||||||||||||
| 23 | 0 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 24 | 0 | my ($filename, $mode, $perms, $close_callback) = @_; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | my $self = $class->SUPER::new($filename, $mode, $perms) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | or return undef; | ||||||||||||||||||||
| 28 | 0 | bless $self, $class; | |||||||||||||||||||
| 29 | 0 | *$self->{_cache_close_callback} = $close_callback; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | return $self; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | ▶ | sub open { | ||||||||||||||||||
|
Subroutine
open: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 35 | 0 | my $self = shift; | |||||||||||||||||||
| 36 | 0 | my ($filename, $mode, $perms, $close_callback) = @_; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | *$self->{_cache_close_callback} = $close_callback; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | return $self->SUPER::open($filename, $mode, $perms); | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | sub close { | ||||||||||||||||||
|
Subroutine
close: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 44 | 0 | my $self = shift; | |||||||||||||||||||
| 45 | 0 | $self->flush; | |||||||||||||||||||
| 46 | 0 | ▶ | *$self->{_cache_close_callback}->($self) if *$self->{_cache_close_callback}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 0 | delete *$self->{_cache_close_callback}; | |||||||||||||||||||
| 48 | 0 | $self->SUPER::close(@_); | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||
|
Subroutine
DESTROY: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 52 | 0 | my $self = shift; | |||||||||||||||||||
| 53 | 0 | ▶ | *$self->{_cache_close_callback}->($self) if *$self->{_cache_close_callback}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | #$self->SUPER::DESTROY(); | ||||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 1 | 1; | |||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||