File Coverage

blib/lib/Message/Passing/Filter/T.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 18 18 100.0


line stmt bran cond sub pod time code
1             package Message::Passing::Filter::T;
2 2     2   957 use Moo;
  2         5  
  2         11  
3 2     2   570 use MooX::Types::MooseLike::Base qw/ ArrayRef /;
  2         4  
  2         122  
4 2     2   12 use namespace::clean -except => 'meta';
  2         4  
  2         13  
5              
6             with 'Message::Passing::Role::Input';
7             with 'Message::Passing::Role::Output';
8              
9             has '+output_to' => (
10             # isa => ArrayRef[role_type('Message::Passing::Role::Output')],
11             is => 'ro',
12             required => 1,
13             );
14              
15             sub consume {
16 2     2 1 449 my ($self, $message) = @_;
17 2         4 foreach my $output_to (@{ $self->output_to }) {
  2         10  
18 3         110 $output_to->consume($message);
19             }
20             }
21              
22              
23             1;
24              
25             =head1 NAME
26              
27             Message::Passing::Filter::T - Send a message stream to multiple outputs.
28              
29             =head1 DESCRIPTION
30              
31             This filter is used to duplicate a message stream to two or more outputs.
32              
33             All messages are duplicated to all output streams, so you may want to follow
34             this with L<Message::Passing::Filter::Key> to one or more of those streams.
35              
36             =head1 ATTRIBUTES
37              
38             =head2 output_to
39              
40             Just like a normal L<Message::Passing::Role::Input> class, except takes an array of outputs.
41              
42             =head1 METHODS
43              
44             =head2 consume
45              
46             Sends the consumed message to all output_to instances.
47              
48             =head1 SPONSORSHIP
49              
50             This module exists due to the wonderful people at Suretec Systems Ltd.
51             <http://www.suretecsystems.com/> who sponsored its development for its
52             VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with
53             the SureVoIP API -
54             <http://www.surevoip.co.uk/support/wiki/api_documentation>
55              
56             =head1 AUTHOR, COPYRIGHT AND LICENSE
57              
58             See L<Message::Passing>.
59              
60             =cut