Peter Makholm


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


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

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

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

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


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


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.


Peter Makholm <>


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.