| 1 | package Purple::Server; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 2 | our $VERSION = '0.9'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 2 | my $DEFAULT_SERVER = 'REST'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 1 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||
| 10 | 1 | my $class = shift; | |||||||||||||||||||
| 11 | 1 | my %p = @_; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 1 | ▶ | $p{type} ||= $DEFAULT_SERVER; | ||||||||||||||||||
|
Condition33%1/3
$p{"type"} ||= $DEFAULT_SERVER
MC/DC0%0/2
$p{"type"} ||= $DEFAULT_SERVER
$p{"type"}
$DEFAULT_SERVER
Truth table33%1/3
A ||= B
A= $p{"type"}B= $DEFAULT_SERVER
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 1 | my $real_class = 'Purple::Server::' . $p{type}; | |||||||||||||||||||
| 16 | 1 | ▶ | unless ( $real_class->can('_New') ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 17 | 1 | eval "require $real_class"; | |||||||||||||||||||
| 18 | 1 | ▶ | die "Unable to load $real_class: $@" if $@; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | 1 | delete $p{type}; | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 1 | return $real_class->_New(%p); | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | =head1 NAME | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | Purple::Server - Factory class for generating servers for Purple Numbers | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | =head1 VERSION | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | Version 0.9 | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | =head1 SYNOPSIS | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | See the default implementation L<Purple::Server::REST>. | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | =head1 METHODS | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | =head2 new(%options) | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | You can specify an alternative server by passing: | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | type => 'server' | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | where 'server' is the name of the server type. If you don't pass this | ||||||||||||||||||||
| 46 | parameter, it will default to REST. | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =head1 AUTHOR | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | Chris Dent, E<lt>cdent@burningchrome.comE<gt> | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | Eugene Eric Kim, E<lt>eekim@blueoxen.comE<gt> | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =head1 BUGS | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | Please report any bugs or feature requests to | ||||||||||||||||||||
| 57 | C<bug-purple@rt.cpan.org>, or through the web interface at | ||||||||||||||||||||
| 58 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Purple>. | ||||||||||||||||||||
| 59 | I will be notified, and then you'll automatically be notified of progress on | ||||||||||||||||||||
| 60 | your bug as I make changes. | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | (C) Copyright 2006 Blue Oxen Associates. All rights reserved. | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||
| 69 | under the same terms as Perl itself. | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 2 | 1; # End of Purple | |||||||||||||||||||