MessageBus/Message.pm

filter: Statementstmt 100% 21 / 21 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 100% 29 / 29 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« MessageBus/Base.pm ↑ Summary
1 package Net::MessageBus::Message;
2  
3 4 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 =head1 NAME
8  
9 Net::MessageBus::Message - Pure Perl generic message queue
10  
11 =head1 VERSION
12  
13 Version 0.08
14  
15 =cut
16  
17 4 our $VERSION = '0.08';
18  
19 4 ▶use base qw(Class::Accessor);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 4 __PACKAGE__->mk_ro_accessors(qw(type group sender payload));
22  
23  
24 =head1 SYNOPSIS
25  
26 This module implements a pure perl message bus message object
27  
28 Example :
29  
30 use Net::MessageBus::Message;
31  
32 my $foo = Net::MessageBus::Message->new(
33 type => 'event',
34 payload => { some => 'complex strcture' },
35 sender => 'script1',
36 group => 'backend',
37 );
38 ...
39  
40  
41 =head1 SUBROUTINES/METHODS
42  
43 =head2 new
44  
45 Creates a new Net::MessageBus::Message object
46  
47 B<Arguments>
48  
49 =over
50  
51 =item * type = A type assigned to the message
52  
53 =item * payload = A complex perl structure / scalar but it cannot contain any objects
54  
55 =item * sender = the name of the Net::MessageBus client that is sending the message
56  
57 =item * group = the group to which this message belongs
58  
59 =back
60  
61 B<Example> :
62
63 my $foo = Net::MessageBus::Message->new(
64 type => 'event',
65 payload => { some => 'complex strcture' },
66 sender => 'script1',
67 group => 'backend',
68 );
69  
70 =cut
71  
72 612 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
73 612 my $class = shift;
74 612 my %params = %{shift()};
75
76 612 my $self = __PACKAGE__->SUPER::new({%params});
77
78 612 return $self;
79 }
80  
81 =head2 type
82  
83 Returns the type of the message
84  
85 B<Example> :
86
87 my $type = $Message->type();
88
89 =head2 sender
90  
91 Returns the sender of the message
92  
93 B<Example> :
94  
95 my $type = $Message->sender();
96
97 =head2 group
98  
99 Returns the group of the message
100  
101 B<Example> :
102  
103 my $type = $Message->group();
104
105 =head2 payload
106  
107 Returns the payload of the message
108  
109 B<Example> :
110  
111 my $type = $Message->payload();
112  
113  
114 =head1 Private methods
115  
116 =head2 serialize
117  
118 Serializes the message for transport
119  
120 =cut
121  
122 207 ▶sub serialize {
Subroutine serialize: called CC=1 SCAR=0.0
Pod documented
123 207 my $self = shift;
124
125 return {
126 207 sender => $self->sender(),
127 group => $self->group(),
128 type => $self->type(),
129 payload => $self->payload()
130 };
131 }
132  
133 =head1 AUTHOR
134  
135 Horea Gligan, C<< <gliganh at gmail.com> >>
136  
137 =head1 BUGS
138  
139 Please report any bugs or feature requests to C<bug-net-MessageBus at rt.cpan.org>, or through
140 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-MessageBus>. I will be notified, and then you'll
141 automatically be notified of progress on your bug as I make changes.
142  
143  
144  
145  
146 =head1 SUPPORT
147  
148 You can find documentation for this module with the perldoc command.
149  
150 perldoc Net::MessageBus::Message
151  
152  
153 You can also look for information at:
154  
155 =over 4
156  
157 =item * RT: CPAN's request tracker (report bugs here)
158  
159 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-MessageBus>
160  
161 =item * AnnoCPAN: Annotated CPAN documentation
162  
163 L<http://annocpan.org/dist/Net-MessageBus>
164  
165 =item * CPAN Ratings
166  
167 L<http://cpanratings.perl.org/d/Net-MessageBus>
168  
169 =item * Search CPAN
170  
171 L<http://search.cpan.org/dist/Net-MessageBus/>
172  
173 =back
174  
175  
176 =head1 ACKNOWLEDGEMENTS
177  
178  
179 =head1 LICENSE AND COPYRIGHT
180  
181 Copyright 2012 Horea Gligan.
182  
183 This program is free software; you can redistribute it and/or modify it
184 under the terms of either: the GNU General Public License as published
185 by the Free Software Foundation; or the Artistic License.
186  
187 See http://dev.perl.org/licenses/ for more information.
188  
189  
190 =cut
191  
192 4 1; # End of Net::MessageBus::Message
« MessageBus/Base.pm ↑ Summary