File Coverage

blib/lib/Message/Passing/AMQP/Role/HasAChannel.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             package Message::Passing::AMQP::Role::HasAChannel;
2 1     1   796 use Moose::Role;
  1         2  
  1         92  
3 1     1   6049 use Scalar::Util qw/ weaken /;
  1         2  
  1         49  
4 1     1   6 use AnyEvent;
  1         2  
  1         27  
5 1     1   155 use AnyEvent::RabbitMQ;
  0            
  0            
6             use namespace::autoclean;
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             my ($self, $connection) = @_;
18             weaken($self);
19             $connection->open_channel(
20             on_success => sub {
21             my $channel = shift;
22             $self->_set_channel($channel);
23             },
24             on_failure => sub {
25             $self->_clear_channel;
26             },
27             on_close => sub {
28             $self->_clear_channel;
29             },
30             );
31             }
32             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