| 1 | package Catalyst::Plugin::XMLRPC::DispatchType::XMLRPC; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base qw/Catalyst::DispatchType/; | ||
| 5 | use Text::SimpleTable; | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Catalyst::Plugin::XMLRPC::DispatchType::XMLRPC - XMLRPC DispatchType | ||
| 10 | |||
| 11 | =head1 SYNOPSIS | ||
| 12 | |||
| 13 | See L<Catalyst::Plugin::XMLRPC>. | ||
| 14 | |||
| 15 | =head1 DESCRIPTION | ||
| 16 | |||
| 17 | =head1 METHODS | ||
| 18 | |||
| 19 | =head2 $self->list($c) | ||
| 20 | |||
| 21 | Debug output for XMLRPC dispatch points | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | sub list { | ||
| 26 | my ( $self, $c ) = @_; | ||
| 27 | my $methods = Text::SimpleTable->new( [ 35, 'Method' ], [ 36, 'Private' ] ); | ||
| 28 | for my $method ( sort keys %{ $self->{methods} } ) { | ||
| 29 | my $action = $self->{methods}->{$method}; | ||
| 30 | $methods->row( "$method", "/$action" ); | ||
| 31 | } | ||
| 32 | $c->log->debug( "Loaded XMLRPC Methods:\n" . $methods->draw ) | ||
| 33 | if ( keys %{ $self->{methods} } ); | ||
| 34 | } | ||
| 35 | |||
| 36 | =head2 $self->match($c) | ||
| 37 | |||
| 38 | Do nothing | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | sub match { return 0 } | ||
| 43 | |||
| 44 | =head2 $self->register( $c, $action ) | ||
| 45 | |||
| 46 | Call register_path for every path attribute in the given $action. | ||
| 47 | |||
| 48 | =cut | ||
| 49 | |||
| 50 | sub register { | ||
| 51 | my ( $self, $c, $action ) = @_; | ||
| 52 | |||
| 53 | my @register = @{ $action->attributes->{XMLRPC} || [] }; | ||
| 54 | |||
| 55 | for my $method (@register) { | ||
| 56 | $method ||= "$action"; | ||
| 57 | $method =~ s#/#.#g; | ||
| 58 | $self->{methods}{$method} = $action; | ||
| 59 | } | ||
| 60 | |||
| 61 | return 1 if @register; | ||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | |||
| 65 | =head1 AUTHOR | ||
| 66 | |||
| 67 | Sebastian Riedel, C<sri@cpan.org> | ||
| 68 | |||
| 69 | =head1 COPYRIGHT | ||
| 70 | |||
| 71 | This program is free software, you can redistribute it and/or modify it under | ||
| 72 | the same terms as Perl itself. | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | 1; |