Fotango Ltd > Froody-42.041_2 > Froody::Implementation

Download:
Froody-42.041_2.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Froody::Implementation - define what should be run for a Froody::Method

SYNOPSIS ^

  # run the code from the froody method
  my $implementation_obj = $froody_method->implementation();
  my $response = $implementation_obj->invoke($froody_method, \%params);
  $response->render;

DESCRIPTION ^

You probably don't care about this class unless you want to change the way that your Perl code is called for a given method (e.g. you want to dynamically create methods or do something clever with sessions.)

Froody::Implementation and its subclasses are responsible for implementing the Perl code that is run when a Froody::Method is called. Essentially a Froody::Method only really knows what it's called and that the instance of another class - its implementation - knows how to run the code.

In reality, all a Froody::Implementation really has to do is implement an invoke method, that when passed a Froody::Method and a hashref containing named parameters can 'execute' that method and return a Froody::Response:

  my $response = $implementation_obj->invoke($froody_method, $hash_params);

This module provides a default implementation that calculates a Perl method name by transforming the Froody::Method name. Before it runs that method it pokes around with the arguments passed in based on the Froody::Method's arguments. When that Perl method returns, it transforms the hashref that code returned into a proper Froody::Response based on the response defined for the Froody::Method that is being processed. Essentially, it wraps the Perl code that you have to write in such a way you don't even have to think about what's going on from Froody's point of view.

METHODS ^

$self->repository

A get/set accessor that gets/sets what repository this invoker is associated with. This is a weak reference.

$self->get_invoke_function( name )

returns the function to be called to invoke a method. Simply returns the result of 'can' in the default implementation.

$self->module($method)

Given a Froody::Method object, require and return the module that the method will be dispatched to.

$self->create_context($params)

Returns the context of the current invocation. By default this return the class, so it's not instantiating. Override this to provide session management in store_context.

$self->store_context($response)

Serialize the current context into $response. By default this does nothing, you can override this and add a cookie to the response object.

$context->pre_process($method, $params)

Called by invoke before the actual method call.

$context->post_process($method, $data)

Builds a Froody::Response::Terse object according to the method's response specification and the data returned from the method.

$context->error_handler($method_name, $error)

SEE ALSO ^

Froody::Repository, Froody::API and for other implementations Froody::Implementation::OneClass and Froody::Implementation::Remote

AUTHORS ^

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.

syntax highlighting: