YMSG/ChangeState.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 59 CC 8 SCAR 21.9
CC
8
Cov
0%
source
20.0
from
6.0
body
6.0
CRAP 8.9
1 package Net::YMSG::ChangeState;
2 use base 'Net::YMSG::Event';
3  
4  
5 sub source
6 {
7 my $self = shift;
8 if (@_) {
9 $self->SUPER::source(@_);
10 my $yahoo = $self->get_connection;
11 my $buddy = $yahoo->get_buddy_by_name($self->from);
12 return unless $buddy;
13  
14 $buddy->status($self->status_code);
15 if ($self->status_code == 99) {
16 $buddy->custom_status($self->body);
17 $buddy->busy($self->busy);
18 }
19 }
20 $self->SUPER::source();
21 }
22  
23 sub from
24 {
25 my $self = shift;
26 $self->_set_by_name('BUDDY_ID', shift) if @_;
27 $self->_get_by_name('BUDDY_ID');
28 }
29  
30  
31 sub body
32 {
33 my $self = shift;
34 $self->_set_by_name('STATUS_MESSAGE', shift) if @_;
35 $self->_get_by_name('STATUS_MESSAGE');
36 }
37  
38 sub busy
39 {
40 my $self = shift;
41 $self->_set_by_name('BUSY_CODE', shift) if @_;
42 $self->_get_by_name('BUSY_CODE');
43 }
44  
45 sub status_code
46 {
47 my $self = shift;
48 $self->_set_by_name('STATUS_CODE', shift) if @_;
49 $self->_get_by_name('STATUS_CODE');
50 }
51  
52  
53 sub code
54 {
55 return 3
56 }
57  
58  
59 sub to_string
60 {
61 my $self = shift;
62 sprintf "%s: transit to '%s'", $self->{sender}, $self->{body};
63 }
64  
65 1;
66 __END__