| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Notify::Notice; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | require 5.00503; | 
| 4 | 2 |  |  | 2 |  | 1828 | use strict; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 58 |  | 
| 5 | 2 |  |  | 2 |  | 9 | use Carp; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 321 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | require Exporter; | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | our @ISA = qw( Exporter ); | 
| 10 |  |  |  |  |  |  | our %EXPORT_TAGS = ( | 
| 11 |  |  |  |  |  |  | 'all' => [qw( EMPTY OUTGOING_PENDING WAITING_RESPONSE WAITING_PROCESSING FAILURE DONE )] | 
| 12 |  |  |  |  |  |  | ); | 
| 13 |  |  |  |  |  |  | our @EXPORT_OK = qw( ); | 
| 14 |  |  |  |  |  |  | our @EXPORT = ( @{ $EXPORT_TAGS{'all'} } ); | 
| 15 |  |  |  |  |  |  | #our $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; | 
| 16 |  |  |  |  |  |  | our $VERSION = '0.0.1'; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | # Constants that indicate notification status | 
| 19 | 2 |  |  | 2 |  | 9 | use constant EMPTY              => 0; | 
|  | 2 |  |  |  |  | 6 |  | 
|  | 2 |  |  |  |  | 160 |  | 
| 20 | 2 |  |  | 2 |  | 10 | use constant OUTGOING_PENDING   => 1; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 78 |  | 
| 21 | 2 |  |  | 2 |  | 9 | use constant WAITING_RESPONSE   => 2; | 
|  | 2 |  |  |  |  | 8 |  | 
|  | 2 |  |  |  |  | 270 |  | 
| 22 | 2 |  |  | 2 |  | 9 | use constant WAITING_PROCESSING => 3; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 102 |  | 
| 23 | 2 |  |  | 2 |  | 9 | use constant FAILURE            => 4; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 78 |  | 
| 24 | 2 |  |  | 2 |  | 9 | use constant DONE               => 5; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 710 |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | our @attribs = qw( status attempts id src dest message transport time_created time_updated history ); | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | sub new { | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 2 |  |  | 2 | 0 | 910 | my ($self, $hash_vals) = @_; | 
| 31 | 2 |  | 33 |  |  | 15 | my $class = ref($self) || $self; | 
| 32 | 2 |  |  |  |  | 4 | my $this = {}; | 
| 33 | 2 |  |  |  |  | 6 | bless $this, $class; | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | # Set our notification attribs to a blank hash | 
| 36 | 2 |  |  |  |  | 15 | $this->{'__ATTRIBS'} = { }; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | # Copy in preset values | 
| 39 | 2 |  |  |  |  | 8 | foreach (@attribs) { | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 20 | 50 |  |  |  | 41 | $this->{'__ATTRIBS'}->{$_} = $hash_vals->{$_} | 
| 42 |  |  |  |  |  |  | if exists $hash_vals->{$_}; | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 2 |  |  |  |  | 9 | return $this; | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | } #end sub new | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | sub attribs { | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 0 |  |  | 0 | 0 |  | my ($self) = @_; | 
| 53 | 0 |  |  |  |  |  | return @attribs; | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | } #end sub attribs | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub getNotice { | 
| 58 |  |  |  |  |  |  |  | 
| 59 | 0 |  |  | 0 | 0 |  | my ($self) = @_; | 
| 60 |  |  |  |  |  |  | # Return a copy of the hash | 
| 61 | 0 |  |  |  |  |  | return \%{ $self->{'__ATTRIBS'} }; | 
|  | 0 |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | } #end sub getNotice | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | sub setNotice { | 
| 66 |  |  |  |  |  |  |  | 
| 67 | 0 |  |  | 0 | 0 |  | my ($self, $attribs) = @_; | 
| 68 |  |  |  |  |  |  |  | 
| 69 | 0 | 0 | 0 |  |  |  | confess "Error: Must receive hash reference to set Notice attributes." | 
| 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 | 0 |  |  |  |  | $self->{'__ATTRIBS'}->{$_} = $attribs->{$_} | 
| 76 |  |  |  |  |  |  | if grep /^$_$/, @attribs; | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | } | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | } #end sub setNotice | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | 1; | 
| 83 |  |  |  |  |  |  |  | 
| 84 |  |  |  |  |  |  | __END__ |