File Coverage

blib/lib/Message/Passing/Output/Callback.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Message::Passing::Output::Callback;
2 13     13   7273 use Moo;
  13         43  
  13         78  
3 13     13   4397 use MooX::Types::MooseLike::Base qw/ CodeRef /;
  13         37  
  13         884  
4 13     13   105 use namespace::clean -except => 'meta';
  13         28  
  13         99  
5              
6             has cb => (
7             isa => CodeRef,
8             is => 'ro',
9             );
10              
11             sub consume {
12 27     27 1 4707 my ($self, $msg) = @_;
13 27         107 $self->cb->($msg);
14             }
15              
16             with 'Message::Passing::Role::Output';
17              
18              
19             1;
20              
21             =head1 NAME
22              
23             Message::Passing::Output::Callback - Output to call back into your code
24              
25             =head1 SYNOPSIS
26              
27             Message::Passing::Output::Callback->new(
28             cb => sub {
29             my $message = shift;
30             },
31             );
32              
33             =head1 METHODS
34              
35             =head2 cb
36              
37             The callback to be called when a message is received.
38              
39             =head2 consume ($msg)
40              
41             Calls the callback with the message as its first parameter.
42              
43             =head1 SEE ALSO
44              
45             L<Message::Passing>
46              
47             =head1 SPONSORSHIP
48              
49             This module exists due to the wonderful people at Suretec Systems Ltd.
50             <http://www.suretecsystems.com/> who sponsored its development for its
51             VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with
52             the SureVoIP API -
53             <http://www.surevoip.co.uk/support/wiki/api_documentation>
54              
55             =head1 AUTHOR, COPYRIGHT AND LICENSE
56              
57             See L<Message::Passing>.
58              
59             =cut