Server/Bayeux/Message/Factory.pm

filter: Statementstmt 54.1% 13 / 24 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 47.2% 17 / 36 CC 4 SCAR 23.5
CC
4
Cov
43%
create
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 10.5
« Server/Bayeux/Message/Publish.pm ↑ Summary Server/Bayeux/Utilities.pm »
1 package POE::Component::Server::Bayeux::Message::Factory;
2  
3 =head1 NAME
4  
5 POE::Component::Server::Bayeux::Message::Factory - create messages in the right subclass
6  
7 =head1 DESCRIPTION
8  
9 Implements create(), which will find the appropriate Message subclass to handle the data packet.
10  
11 =cut
12  
13 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use POE qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
16 Component::Server::Bayeux::Message::Invalid
17 Component::Server::Bayeux::Message::Meta
18 Component::Server::Bayeux::Message::Service
19 Component::Server::Bayeux::Message::Publish
20 3 );
21  
22 3 ▶use Params::Validate qw(validate HASHREF ARRAYREF);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 0 ▶sub create {
Subroutine create: not called CC=4 SCAR=30.0
Pod undocumented
25 0 my $class = shift;
26  
27 0 my %args = validate(@_, {
28 request => 1,
29 data => { type => HASHREF },
30 });
31  
32 0 my $channel = $args{data}{channel};
33  
34 0 my $build_class;
35 0 ▶ if (! $channel) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $channel) { } 0 0 0
elsif ($channel =~ m[^/meta/]) { } 0 0 0
elsif ($channel =~ m[^/service/]) { } 0 0 0
36 0 $build_class = 'Invalid';
37 }
38 elsif ($channel =~ m{^/meta/}) {
39 0 $build_class = 'Meta';
40 }
41 elsif ($channel =~ m{^/service/}) {
42 0 $build_class = 'Service';
43 }
44 else {
45 0 $build_class = 'Publish';
46 }
47  
48 0 $build_class = 'POE::Component::Server::Bayeux::Message::' . $build_class;
49 0 return $build_class->new(%args);
50 }
51  
52 =head1 COPYRIGHT
53  
54 Copyright (c) 2008 Eric Waters and XMission LLC (http://www.xmission.com/).
55 All rights reserved. This program is free software; you can redistribute it
56 and/or modify it under the same terms as Perl itself.
57  
58 The full text of the license can be found in the LICENSE file included with
59 this module.
60  
61 =head1 AUTHOR
62  
63 Eric Waters <ewaters@uarc.com>
64  
65 =cut
66  
67 3 1;
« Server/Bayeux/Message/Publish.pm ↑ Summary Server/Bayeux/Utilities.pm »