| 1 | package Message::Passing::Output::Callback; | ||
| 2 | 13 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 13 | ▶ | use MooX::Types::MooseLike::Base qw/ CodeRef /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 13 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 13 | has cb => ( | |
| 7 | isa => CodeRef, | ||
| 8 | is => 'ro', | ||
| 9 | ); | ||
| 10 | |||
| 11 | sub consume { | ||
| 12 | 27 | ▶ | my ($self, $msg) = @_; |
|
Subroutine
consume: called CC=1 SCAR=0.0
Pod
documented
| |||
| 13 | 27 | $self->cb->($msg); | |
| 14 | } | ||
| 15 | |||
| 16 | 13 | with 'Message::Passing::Role::Output'; | |
| 17 | |||
| 18 | |||
| 19 | 13 | 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<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 | ||