NAME

Froody::Implementation - define Perl methods to implement Froody::Method

SYNOPSIS

 package MyCompany::PerlMethods::Time;
 use base qw(Froody::Implementation);

 # say what api you're implementing, and what subset of those methods
 # should be handled by perl methods in this class
 sub implements { "MyCompany::API" => "mycompany.timequery.*" }

 use DateTime;

 # this is mycompany.timequery.gettime
 sub gettime
 {
    my $self = shift;
    my $args = shift;

    $now = DateTime->now;
    $now->set_time_zone($args->{time_zone}) if $args->{time_zone};
    return $now->datetime;
 }
 
 ...

DESCRIPTION

This class is a simple base class that allows you to quickly and simply provide code for Froody to run when it needs to execute a method.

How to write your methods

It's fairly straightforward to write methods for Froody, and is best demonstrated with an example. Imagine we've got a Froody::Method that's been defined like so:

package PerlService::API;
use base qw(Froody::API::XML);
1;

sub xml { <<'XML';
<spec>
 <methods>
  <method name="perlservice.corelist.released">
    <arguments>
      <argument name="module" type="text" optional="0" />
    </arguments>
    <response>
      <module name="">
        <in version=""></in>
      </module>
    </response>
  </method>
 </methods>
</spec>
XML

We are now ready to start writing a class implementing this API:

package MyCompany::PerlMethods;
use base qw(Froody::Implementation);

sub implements { "MyCompany::API" => "mycompany.timequery.datetime" }

The methods will be called with two parameters, a Froody::Invoker::Implementation object and a hashref containing the method arguments. The arguments will have already been pre-processed to verify that they are all there and of the right type, for example. Look at Froody::Invoker::Implementation if you want to change the behaviour of this pre-processing (you can use this to implement authentication common for all methods, for example).

Abstract methods

implements()

Should return a hash of

Namespace => 'method.names.*'

mappings specifying in what modules the given methods are implemented.

Instance methods

invoker_class()

Returns the class of the invoker. Override this if you need to do fancy checking in the invoker (for sessions or similar).

BUGS

You can't use this to run code for a Froody::Method whose full name ends with ".implements", ".invoker_class" or ".register_in_repository" as those methods are special. Sorry.

Please report any bugs you find via the CPAN RT system. http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody

AUTHOR

Copyright Fotango 2005. All rights reserved.

Please see the main Froody documentation for details of who has worked on this project.

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

SEE ALSO

Froody, Froody::Invoker::Implementation