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   8334 use Moo;
  13         28  
  13         79  
3 13     13   4506 use MooX::Types::MooseLike::Base qw/ CodeRef /;
  13         26  
  13         843  
4 13     13   88 use namespace::clean -except => 'meta';
  13         116  
  13         124  
5              
6             has cb => (
7             isa => CodeRef,
8             is => 'ro',
9             );
10              
11             sub consume {
12 27     27 1 5739 my ($self, $msg) = @_;
13 27         184 $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 it's first parameter
42              
43             =head1 SEE ALSO
44              
45             L
46              
47             =head1 SPONSORSHIP
48              
49             This module exists due to the wonderful people at Suretec Systems Ltd.
50             who sponsored its development for its
51             VoIP division called SureVoIP for use with
52             the SureVoIP API -
53            
54              
55             =head1 AUTHOR, COPYRIGHT AND LICENSE
56              
57             See L.
58              
59             =cut