Purple::Server - Factory class for generating servers for Purple Numbers


Purple documentation Contained in the Purple distribution.

Index


Code Index:

NAME

Top

Purple::Server - Factory class for generating servers for Purple Numbers

VERSION

Top

Version 0.9

SYNOPSIS

Top

See the default implementation Purple::Server::REST.

METHODS

Top

new(%options)

You can specify an alternative server by passing:

  type => 'server'

where 'server' is the name of the server type. If you don't pass this parameter, it will default to REST.

AUTHOR

Top

Chris Dent, <cdent@burningchrome.com>

Eugene Eric Kim, <eekim@blueoxen.com>

BUGS

Top

Please report any bugs or feature requests to bug-purple@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Purple. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Purple documentation Contained in the Purple distribution.

package Purple::Server;

use warnings;
use strict;
our $VERSION = '0.9';

my $DEFAULT_SERVER = 'REST';

sub new {
    my $class = shift;
    my %p = @_;

    $p{type} ||= $DEFAULT_SERVER;

    my $real_class = 'Purple::Server::' . $p{type};
    unless ( $real_class->can('_New') ) {
        eval "require $real_class";
        die "Unable to load $real_class: $@" if $@;
    }
    delete $p{type};

    return $real_class->_New(%p);
}

1;    # End of Purple