File Coverage

blib/lib/AnyEvent/XMPP/Extendable.pm
Criterion Covered Total %
statement 6 13 46.1
branch 0 2 0.0
condition n/a
subroutine 2 5 40.0
pod 2 2 100.0
total 10 22 45.4


line stmt bran cond sub pod time code
1             package AnyEvent::XMPP::Extendable;
2 1     1   1425 no warnings;
  1         2  
  1         42  
3 1     1   5 use strict;
  1         2  
  1         157  
4              
5             =head1 NAME
6              
7             AnyEvent::XMPP::Extendable - Extendable baseclass
8              
9             =head1 DESCRIPTION
10              
11             This class provides a mechanism to add extensions.
12             Please note that the class that derives from this must also
13             derive from L!
14              
15             Please see L for more information about this mechanism.
16              
17             =over 4
18              
19             =item B
20              
21             This method extends the current object with a L object.
22             C<$ext> must be an instance of L.
23              
24             Basically C makes the extension an event receiver
25             for all events that the extended object receives.
26              
27             =cut
28              
29             sub add_extension {
30 0     0 1   my ($self, $ext) = @_;
31             $self->add_forward ($ext, sub {
32 0     0     my ($self, $ext, $ev, @args) = @_;
33 0 0         return if $ext->{inhibit_forward}->{$ev};
34 0           $ext->_event ($ev, $self, @args);
35 0           });
36             }
37              
38             =item B
39              
40             This method removes the extension C<$ext>.
41              
42             =cut
43              
44             sub remove_extension {
45 0     0 1   my ($self, $ext) = @_;
46 0           $self->remove_forward ($ext);
47             }
48              
49              
50             =back
51              
52             =head1 AUTHOR
53              
54             Robin Redeker, C<< >>, JID: C<< >>
55              
56             =head1 COPYRIGHT & LICENSE
57              
58             Copyright 2007, 2008 Robin Redeker, all rights reserved.
59              
60             This program is free software; you can redistribute it and/or modify it
61             under the same terms as Perl itself.
62              
63             =cut
64              
65             1; # End of AnyEvent::XMPP