| 1 | # BW::Jumptable.pm | ||||||||||
| 2 | # Jump table support for BW::* | ||||||||||
| 3 | # | ||||||||||
| 4 | # by Bill Weinman - http://bw.org/ | ||||||||||
| 5 | # Copyright (c) 1995-2010 The BearHeart Group, LLC | ||||||||||
| 6 | # | ||||||||||
| 7 | # See POD for History | ||||||||||
| 8 | |||||||||||
| 9 | package BW::Jumptable; | ||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use base qw( BW::Base ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 1 | ▶ | use BW::Constants; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 1 | our $VERSION = "1.3.1"; | |||||||||
| 17 | |||||||||||
| 18 | sub _init | ||||||||||
| 19 | 0 | ▶ | { | ||||||||
|
Subroutine
_init: not called CC=2 SCAR=17.9
| |||||||||||
| 20 | 0 | my $self = shift; | |||||||||
| 21 | 0 | $self->SUPER::_init(@_); | |||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | return FAILURE unless $self->{jumptable}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 0 | return SUCCESS; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | # _setter_getter entry points | ||||||||||
| 29 | 0 | ▶ | sub jumptable { BW::Base::_setter_getter(@_); } | ||||||||
|
Subroutine
jumptable: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | |||||||||||
| 31 | sub jump | ||||||||||
| 32 | 0 | ▶ | { | ||||||||
|
Subroutine
jump: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 33 | 0 | my $sn = 'jump'; | |||||||||
| 34 | 0 | my $self = shift; | |||||||||
| 35 | 0 | my $action = shift; | |||||||||
| 36 | |||||||||||
| 37 | 0 | ▶ | return $self->_error("$sn: no action") unless $action; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | |||||||||||
| 39 | 0 | foreach my $j ( keys %{ $self->{jumptable} } ) { | |||||||||
| 40 | 0 | ▶ | if ( $j eq $action ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | &{ $self->{jumptable}{$j} }(); | |||||||||
| 42 | 0 | return SUCCESS; | |||||||||
| 43 | } | ||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 0 | return $self->_error("$sn: action not found ($action)"); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 1 | 1; | |||||||||
| 50 | |||||||||||
| 51 | __END__ | ||||||||||