NAME
Rose::Planter - Keep track of classes created with Rose::DB::Object::Loader.
SYNOPSIS
In My/Objects.pm :
package My::Objects;
use Rose::Planter
loader_params => {
class_prefix => "My::Object",
db_class => "My::DB",
},
nested_tables => {
foo => [ qw(params) ]
},
convention_manager_params => {};
In plant.pl :
#!/usr/bin/env perl
Rose::Planter->plant("My::Objects" => "My/Objects/autolib");
In another file :
use My::Objects;
my $class = Rose::Planter->find_class("my_table");
my $object = Rose::Planter->find_object("my_table","my_key1","my_key2");
DESCRIPTION
This is a thin layer above Rose::DB::Object::Loader for keeping track of and managing classes which are created based on a database schema. It will transparently either query the database using Rose::DB::Object::Loader or use an auto-generated class hierarchy.
This module works well with Module::Build::Database and Clustericious to create a simple RESTful service based on a database schema. It can be used to provide a common base class, conventions, and settings for a collection of services, as well as describe which tables within a schema should be coupled with other tables during CRUD operations.
By default the loader is told that the base_class should be Rose::Planter::Soil. You can send "base_classes" or just "base_class" as loader_params to changes this.
nested_tables will cause find_object to automatically join tables connected to the primary table with a many-to-one relationship.
FUNCTIONS
plant
Rose::Planter->plant($class => $dir)
Write a class hierarchy to disk.
tables
Return a list of all tables.
regex_for_tables
Create a regex that matches all the tables.
plurals
Return a list of all plurals.
regex_for_plurals
Create a regex that matches all the plurals.
find_class
Given the name of a database table, return the object class associated with it. e.g.
Rose::Planter->find_class("app");
If the table name ends in _def, the prefix may be used, e.g these are equivalent :
Rose::Planter->find_class("esdt_def");
Rose::Planter->find_class("esdt");
Also, given the plural of the name of a database table, return the manager class associated with it.
Rose::Planter->find_class("esdts");
Rose::Planter->find_class("apps");
find_object
Given a table and a primary or other unique key(s), find a load an object.
Return false if there is no object matching that key.
NOTES
This is a beta release. The API is subject to change without notice.
AUTHORS
Marty Brandon
Brian Duggan
Graham Ollis
Curt Tilmes
BUGS
Currently only really used/tested against postgres.