Peter Makholm > AnyEvent-JSONRPC-0.15 > AnyEvent::JSONRPC::Utils

Download:
AnyEvent-JSONRPC-0.15.tar.gz

Annotate this POD

Website

CPAN RT

New  5
Open  0
View/Report Bugs
Source  

NAME ^

AnyEvent::JSONRPC::Utils - Helper functions for use with AnyEvent::JSONRPC

SYNOPSIS ^

    # XXX being either TCP or HTTP
    my $server = AnyEvent::JSONRPC::XXX::Server->new();

    # Delegate methods to an object:
    my $object = Foo->new();
    $server->reg_cb(
        method1 => delegate($object),
    );

    # Delegate methods to another json-rpc server
    my $client = AnyEvent::JSONRPC::XXX::Client->new();
    $server->reg_cb(
        method2 => delegate($client),
    );

    # Delegate all methods from moose object
    my $object = Bar->new();
    $server->reg_cb(
        do_moose($object),
    );

DESCRIPTION ^

This module provides a couple of helper functions for creating JSON-RPC servers. This is kind of experimental at the moment.

FUNCTIONS ^

delegate <$object>

This function returns a generic subroutine usable for registering method calls. The same subroutine can be used for registering multiple methods delegated to the same object.

If $object is a AnyEvent::JSONRPC client method calls will be proxied through this client, otherwise it is assumed to be method calls on the object.

do_moose <$object>

This function returns a complete delegation of methods to a Moose object. Some methods are considered protected and should be explicitly registered if needed. This includes all method names starting with an underscore, all methodnames consisting of only capital letters, and the following methods generated by Moose: new, meta, dump, and does.

AUTHOR ^

Peter Makholm <peter@makholm.net>

COPYRIGHT AND LICENSE ^

Copyright (c) 2010 by Peter Makholm.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

syntax highlighting: