| 1 | package Notify::Notice; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | require 5.00503; | |||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | require Exporter; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | our @ISA = qw( Exporter ); | |||||||||||||||||||||||||||
| 10 | 2 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||
| 11 | 'all' => [qw( EMPTY OUTGOING_PENDING WAITING_RESPONSE WAITING_PROCESSING FAILURE DONE )] | ||||||||||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||||||||||
| 13 | 2 | our @EXPORT_OK = qw( ); | |||||||||||||||||||||||||||
| 14 | 2 | our @EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||
| 15 | #our $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; | ||||||||||||||||||||||||||||
| 16 | 2 | our $VERSION = '0.0.1'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Constants that indicate notification status | ||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use constant EMPTY => 0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use constant OUTGOING_PENDING => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use constant WAITING_RESPONSE => 2; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use constant WAITING_PROCESSING => 3; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use constant FAILURE => 4; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use constant DONE => 5; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 2 | our @attribs = qw( status attempts id src dest message transport time_created time_updated history ); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | my ($self, $hash_vals) = @_; | |||||||||||||||||||||||||||
| 31 | 2 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 32 | 2 | my $this = {}; | |||||||||||||||||||||||||||
| 33 | 2 | bless $this, $class; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Set our notification attribs to a blank hash | ||||||||||||||||||||||||||||
| 36 | 2 | $this->{'__ATTRIBS'} = { }; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | # Copy in preset values | ||||||||||||||||||||||||||||
| 39 | 2 | foreach (@attribs) { | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | $this->{'__ATTRIBS'}->{$_} = $hash_vals->{$_} | ||||||||||||||||||||||||||||
| 42 | 20 | ▶ | if exists $hash_vals->{$_}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 2 | return $this; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | } #end sub new | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub attribs { | ||||||||||||||||||||||||||
|
Subroutine
attribs: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 53 | 0 | return @attribs; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | } #end sub attribs | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub getNotice { | ||||||||||||||||||||||||||
|
Subroutine
getNotice: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 60 | # Return a copy of the hash | ||||||||||||||||||||||||||||
| 61 | 0 | return \%{ $self->{'__ATTRIBS'} }; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | } #end sub getNotice | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub setNotice { | ||||||||||||||||||||||||||
|
Subroutine
setNotice: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | my ($self, $attribs) = @_; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | confess "Error: Must receive hash reference to set Notice attributes." | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$attribs and ref $attribs eq "HASH"
MC/DC0%0/2
$attribs and ref $attribs eq "HASH"
$attribs
ref $attribs eq "HASH"
Truth table0%0/3
A and B
A= $attribsB= ref $attribs eq "HASH"
| |||||||||||||||||||||||||||||
| 70 | unless $attribs and ref ($attribs) eq 'HASH'; | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # Change the internal to reflect the changes | ||||||||||||||||||||||||||||
| 73 | 0 | foreach (keys %$attribs) { | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $self->{'__ATTRIBS'}->{$_} = $attribs->{$_} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | if grep /^$_$/, @attribs; | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | } #end sub setNotice | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 2 | 1; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||