File Coverage

blib/lib/Message/Passing/AMQP/Role/HasAChannel.pm
Criterion Covered Total %
statement 15 22 68.1
branch n/a
condition n/a
subroutine 5 10 50.0
pod 2 2 100.0
total 22 34 64.7


line stmt bran cond sub pod time code
1             package Message::Passing::AMQP::Role::HasAChannel;
2 1     1   509 use Moo::Role;
  1         3  
  1         6  
3 1     1   412 use Scalar::Util qw/ weaken /;
  1         3  
  1         45  
4 1     1   7 use AnyEvent;
  1         2  
  1         31  
5 1     1   7 use AnyEvent::RabbitMQ;
  1         2  
  1         20  
6 1     1   5 use namespace::autoclean;
  1         1  
  1         6  
7              
8             with 'Message::Passing::AMQP::Role::HasAConnection';
9              
10             has _channel => (
11             is => 'ro',
12             writer => '_set_channel',
13             clearer => '_clear_channel',
14             );
15              
16             sub connected {
17 0     0 1   my ($self, $connection) = @_;
18 0           weaken($self);
19             $connection->open_channel(
20             on_success => sub {
21 0     0     my $channel = shift;
22 0           $self->_set_channel($channel);
23             },
24             on_failure => sub {
25 0     0     $self->_clear_channel;
26             },
27             on_close => sub {
28 0     0     $self->_clear_channel;
29             },
30 0           );
31             }
32       0 1   sub disconnected {}
33              
34             1;
35              
36             =head1 NAME
37              
38             Message::Passing::AMQP::Role::HasAChannel - Role for instances which have an AMQP channel.
39              
40             =head1 ATTRIBUTES
41              
42             =head1 METHODS
43              
44             =head2 connected
45              
46             Called when the channel has connected
47              
48             =head2 disconnected
49              
50             Called when the channel disconnects.
51              
52             =head1 AUTHOR, COPYRIGHT AND LICENSE
53              
54             See L<Message::Passing::AMQP>.
55              
56             =cut
57