Daniel Ruoso > Oak-Controller-EntityHelper > Oak::Controller::EntityHelper

Download:
Oak-Controller-EntityHelper-1.8.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Source  

NAME ^

Oak::Controller::EntityHelper - Helper module for accessing DBIEntities from Controller

SYNOPSIS ^

  # This class do not catch any exception, all the exeptions thrown by the entity classes
  # will be propagated
  #########################
  # in the controller...

  use Oak::Controller::EntityHelper qw(list list_related create purge get_data set_data);

  $bag = $self->list
  (
   class => "MyApp::MyDBIEntityClass",
   query => "LIMIT 10, 10 ORDER BY name"
  );

  $bag = $self->list_related
  (
   class => "MyApp::MyDBIEntityClass",
   keys => {myprimary_key => "my_value"},
   query => "LIMIT 10, 10 ORDER BY name",
   relationship => "relationship_name"
  );

  $bag = $self->create
  (
   class => "MyApp::MyDBIEntityClass",
   data => {field1 => "value1"}
  );

  $bag = $self->purge
  (
   class => "MyApp::MyDBIEntityClass",
   keys => {myprimary_key => "my_value"}
  );

  $bag = $self->get_data
  (
   class => "MyApp::MyDBIEntityClass",
   keys => {myprimary_key => "my_value"}
  );

  $bag = $self->set_data
  (
   class => "MyApp::MyDBIEntityClass",
   keys => {myprimary_key => "my_value"},
   data => {myfield => "myvalue"}
  );

DESCRIPTION ^

This is a helper module that exports the methods "list", "list_related", "get_data", "set_data" and "count". Create methods that calls these methods in your controller class.

EXPORTED METHODS ^

list(class => "MyApp::MyDBIEntityClass", query => "LIMIT 10, 10 ORDER BY name")

This methods returns an array of hashes containing the information about the objects in the specified class.

  [
   {field1 => "value1",field2 => "value2"},
   ...
  ]
list_related(class => "MyApp::MyDBIEntityClass", keys => {myprimary_key => "my_value"}, query => "LIMIT 10, 10 ORDER BY name", relationship => "relationship_name")

This methods returns an array of hashes containing the information about the objects in the specified relationship of the specified object (class and keys).

  [
   {field1 => "value1",field2 => "value2"},
   ...
  ]
create(class => "MyApp::MyDBIEntityClass", data => {myfield1 => "myvalue1"})

This method create a object of the specified class with the specified data.

purge(class => "MyApp::MyDBIEntityClass", keys => {myprimary_key => "my_value"})

This method will purge the specified object from the specified class.

get_data(class => "MyApp::MyDBIEntityClass", keys => {myprimary_key => "my_value"})

This method will return a hashref with the object data.

set_data(class => "MyApp::MyDBIEntityClass", keys => {myprimary_key => "my_value"}, data => {myfield1 => "myvalue1"})

This method will set the passed data to the specified object.

remove_relationship("entity_class", {key1 => "value1", key2 => "value2", ...}, "related_class", {key1 => "value1", key2 => "value2", ...}, "Relationship name")

This one creates the DBIEntities with your respective class names ("entity_class" and "related_class") and builds a relationship between them through the given relationship name calling:

$entity->add_relationship("Relationship name", $related);

add_relationship("entity_class", {key1 => "value1", key2 => "value2", ...}, "related_class", {key1 => "value1", key2 => "value2", ...}, "Relationship name")

This one creates the DBIEntities with your respective class names ("entity_class" and "related_class") and destroys the relationship (named by the given relationship name) between them calling:

$entity->remove_relationship("Relationship name", $related);

COPYRIGHT ^

Copyright (c) 2001 Daniel Ruoso <daniel@ruoso.com> Carlos Eduardo de Andrade Brasileiro <eduardo@oktiva.com.br> All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.