View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Fotango Ltd > Froody-42.041_2 > Froody::Response::Terse



Annotate this POD


New  1
Open  0
View/Report Bugs


Froody::Response::Terse - create a response from a Terse data structure


  my $rsp = Froody::Response::Terse->new();
   group => "imperialframeworks"
   person => [
    { nick => "Trelane",  number => "243", name => "Mark Fowler"    }
    { nick => "jerakeen", number => "235", name => "Tom Insam"      }
   -text => "Some of Frameworks went to Imperial Collage"
  print $rsp->render();
  # prints out (more or less)
  <?xml version="1.0" encoding="utf-8" ?>
  <people group="imperialframeworks">
    <person nick="Trelane" number="234"><name>Mark Fowler</name></person>
    <person nick="jerakeen" number="235"><name>Tom Insam</name></person>
    Some of Frameworks went to Imperial Collage


The Terse response class allows you to construct Responses from a very small data structure that is the most logical form for the data to take. It is able to convert the data to XML by virtue of the specification stored in the Froody::Method alone.

The data structure is exactly the same that's returned from a method implementation that's defined in a Froody::Implementation subclass (If you don't know what that is, I'd go read that module's documentation now if I were you.)


create_envelope( XML::Document, XML::Node (content) )

You're given one last shot to change the overall format of the response.

The default behavior injects an <rsp stat='status'> wrapper around the content node.


In addition to the attributes inherited from Froody::Response, this class has the following get/set methods:


The status of the response, should be 'ok' or 'fail' only.


The contents of the data structure. Setting this accessor causes a deep clone of the data structure to happen, meaning that you can add similar content to multiple Response objects by setting on one object, altering, then setting another object.

  my $data = { keywords => [qw( fotango office daytime )] };
  push @{ $data->{keywords} } = "Trelane";

Note however, this is not true for the returned value from content. Altering that data structure really does alter the data in the response (this is considered a feature)

  # add my name as a keyword as well
  push @{ $picture_of_me_in_office->content->{keywords} }, "Mark";

Converting other Responses to Froody::Response::Terse objects

Once you've loaded this class you can automatically convert other Froody::Response class instances to Froody::Response::Terse objects with the as_terse method.

  use Froody::Response::Terse;
  my $terse = Froody::Response::XML
      ->content({ name => "foo", text => "bar" })
  print ref($terse);  # prints "Froody::Response::Terse"


None known.

Please report any bugs you find via the CPAN RT system.


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.


Froody, Froody::Response

syntax highlighting: