File Coverage

blib/lib/POE/Component/YahooMessenger/Event.pm
Criterion Covered Total %
statement 16 37 43.2
branch 0 6 0.0
condition n/a
subroutine 6 17 35.2
pod 0 7 0.0
total 22 67 32.8


line stmt bran cond sub pod time code
1             package POE::Component::YahooMessenger::Event;
2 1     1   13 use strict;
  1         2  
  1         39  
3              
4             BEGIN {
5 1     1   4 use POE::Component::YahooMessenger::Constants;
  1         2  
  1         312  
6              
7             sub _make_body_accessor {
8 32     32   38 my $wantkey = shift;
9             return sub {
10 0     0     my($self, $number) = @_;
11 0           my @values;
12 0           my @params = $self->params;
13 0           while (my($key, $value) = splice(@params, 0, 2)) {
14 0 0         push @values, $value if $key eq $BodyNames->{$wantkey};
15             }
16 0 0         return defined $number ? $values[$number]
    0          
17             : wantarray ? @values : $values[0];
18 32         581 };
19             }
20              
21 1     1   8 for my $name (keys %$BodyNames) {
22 1     1   6 no strict 'refs';
  1         2  
  1         57  
23 32         99 *$name = _make_body_accessor($name);
24             }
25             }
26              
27             sub new_from_body {
28 0     0 0   my($class, $code, $body) = @_;
29 0           bless {
30             code => $code,
31             option => 0, # XXX ?
32             params => [ split /$BodySeparater/, $body ],
33             }, $class;
34             }
35              
36             sub new {
37 0     0 0   my($class, $name, $option, $params) = @_;
38 0           bless {
39             code => $SendEventNames->{$name},
40             option => $option,
41 0           params => [ map { $BodyNames->{$_} => $params->{$_} } keys %$params ],
42             }, $class;
43             }
44              
45 0     0 0   sub code { shift->{code} }
46 0     0 0   sub name { $ReceiveEventCodes->{shift->code} }
47 0     0 0   sub option { shift->{option} }
48              
49             sub body {
50 0     0 0   my $self = shift;
51 0           return join($BodySeparater, $self->params) . $BodySeparater;
52             }
53              
54 0     0 0   sub params { @{shift->{params}} }
  0            
55              
56             package POE::Component::YahooMessenger::Event::Null;
57              
58 1     1   7 use base qw(POE::Component::YahooMessenger::Event);
  1         2  
  1         173  
59              
60 0     0     sub new { bless {}, shift }
61 0     0     sub DESTROY { }
62 0     0     sub AUTOLOAD { }
63              
64             1;