File: Input.pm

package info (click to toggle)
libmessage-passing-perl 0.117-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 544 kB
  • sloc: perl: 2,742; makefile: 2; sh: 1
file content (61 lines) | stat: -rw-r--r-- 1,230 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package Message::Passing::Role::Input;
use Moo::Role;
use Scalar::Util qw/ blessed /;
use Module::Runtime qw/ require_module /;
use namespace::clean -except => 'meta';

has output_to => (
    is => 'ro',
    required => 1,
    isa => sub { blessed($_[0]) && $_[0]->can('consume') },
    coerce => sub {
        my $val = shift;
        if (ref($val) eq 'HASH') {
            my %stuff = %$val;
            my $class = delete($stuff{class});
            require_module($class);
            $val = $class->new(%stuff);
        }
        $val;
    },
);

1;

=head1 NAME

Message::Passing::Role::Input

=head1 DESCRIPTION

Produces messages.

=head1 ATTRIBUTES

=head2 output_to

Required, must perform the L<Message::Passing::Role::Output> role.

=head1 SEE ALSO

=over

=item L<Message::Passing>

=item L<Message::Passing::Manual::Concepts>

=back

=head1 SPONSORSHIP

This module exists due to the wonderful people at Suretec Systems Ltd.
<http://www.suretecsystems.com/> who sponsored its development for its
VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with
the SureVoIP API - 
<http://www.surevoip.co.uk/support/wiki/api_documentation>

=head1 AUTHOR, COPYRIGHT AND LICENSE

See L<Message::Passing>.

=cut