Skip Menu |
 

This queue is for tickets about the JSON-RPC CPAN distribution.

Report information
The Basics
Id: 60346
Status: new
Priority: 0/
Queue: JSON-RPC

People
Owner: Nobody in particular
Requestors: af [...] 0xAF.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: system.listMethods suggestion
Download (untitled) / with headers
text/plain 962b
if one needs system.listMethods here is what i did: ----- >>> ----- package MyApp; use base qw(JSON::RPC::Procedure); sub sum : Public(a:num, b:num) { my ($s, $obj) = @_; # return a scalar value or a hashref or an arryaref. return $obj->{a} + $obj->{b}; } package MyApp::system; use attributes; sub listMethods { my @res; my $pkg = __PACKAGE__; # get package name (MyApp::system) $pkg=~s/system$//; # remove "system" so we have "MyApp::" while (my ($name, $symbol) = each %{$pkg}) { next if $name eq 'BEGIN'; # don't export BEGIN blocks next if $name eq 'import'; # don't export this sub next unless *{$symbol}{CODE}; # export subs only my $attr = attributes::get(*{$symbol}{CODE}); # get attributes next unless ($attr->{return_type} eq 'Public'); # export only Public methods push(@res, $name); } return \@res; } ----- <<< ----- hope this helps to someone perhaps it can be added to the examples and the POD.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.